Why can I not attach an attribute of greater than 256 bytes to a Developer ?

Hi,

I am currently using Developer attributes to store information related to my Developers. In the https://cloud.google.com/apigee/docs/api-platform/reference/limits page it states that attribute values can be up to 2 KB in size. When I was saving some text I wanted to associate with my Developers into an attribute I found it seemed to error far smaller than I was expected. I have some text which when I save it in a plain text file on disk is 256 bytes, but when I post this to my Apigee Developer attribute it will not save. If I reduce it by 1 character it saves fine.

So I have two questions:

  1. How exactly is this 2 KB size calculated as I seem to hit the limit when the plain text size is far below (256 bytes)?
  2. Is there any mechanism I might be mis-understanding or not using that means I can use the full 2 KB in attribute values?

Thanks

Solved Solved
1 5 169
1 ACCEPTED SOLUTION

Hmmm, maybe we are doing this differently. I'm sorry, I should have included this information above. Here's the API I tried.

# update attributes for a developer


POST :mgmtserver/v1/organizations/:org/developers/:dev/attributes
Authorization: Bearer :token
content-type: application/json


{
  "attribute": [
    {
      "name": "new-attr",
      "value": "...many characters here...."
    }
  ]
}
 

As you can see the name value pair is wrapped within an array called "attribute" in the JSON payload. Also I use POST, not PUT.

As far as I know it is not possible to update a single attribute by name. What I mean is if you want to add a single attribute name/value pair to a developer, you must write back a set of attributes, including all of the existing attributes you want to preserve, as well as the attribute you wish to add.

{
  "attribute": [
    {
      "name": "existing-attr-1",
      "value": "...characters representing the existing value...."
    },
    {
      "name": "existing-attr-2",
      "value": "another existing value...."
    },
    {
      "name": "new-attr",
      "value": "...up to 2kb here...."
    }

  ]
}

Can you try it this way?

View solution in original post

5 REPLIES 5

it will not save. If I reduce it by 1 character it saves fine.

Hugo, can you explain what specifically you see or observe when you try to save this attribute? What error message do you see? What specifically are you doing?

And which version of Apigee are you using?

I just tried saving an attribute of 1180 bytes in the Apigee Edge API, it works. I tried in the Apigee Edge UI, it works.

I tried in the Apigee X API, it works.

I tried in the Apigee X UI, it works.

I am performing the following request via the management API: https://apidocs.apigee.com/docs/developers/1/routes/organizations/%7Borg_name%7D/developers/%7Bdevel...

Like: https://api.enterprise.apigee.com/v1/organizations/$org/developers/$dev


This is the attribute I am trying to PUT which fails:

    {
      "name": "test",
      "value": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
    }

I see the following when I go over the size limit:

{
  "code": "mint.unhandledException",
  "message": "Unanticipated exception. Please contact your Support administrator with code : 0aeb2d1f-b6c8-48d1-a02f-3b4780f2a870",
  "contexts": [],
  "cause": {
    "message": "The transaction has been rolled back.  See the nested exceptions for details on the errors that occurred.",
    "contexts": [],
    "cause": {
      "message": "ERROR: current transaction is aborted, commands ignored until end of transaction block {prepstmnt 1602667848 \nUPDATE DEVELOPER \n    SET UPDATED = ? \n    WHERE ID = ? \n} [code=0, state=25P02]",
      "contexts": [],
      "cause": {
        "message": "ERROR: current transaction is aborted, commands ignored until end of transaction block {prepstmnt 1602667848 \nUPDATE DEVELOPER \n    SET UPDATED = ? \n    WHERE ID = ? \n} [code=0, state=25P02]",
        "contexts": []
      }
    }
  }
}

If I remove 1 x character from the value then it succeeds.

Re: version - I am using the hosted Apigee under https://apigee.com/, is there somewhere I can check what version I'm using?

Thanks for getting back to me.

Hmmm, maybe we are doing this differently. I'm sorry, I should have included this information above. Here's the API I tried.

# update attributes for a developer


POST :mgmtserver/v1/organizations/:org/developers/:dev/attributes
Authorization: Bearer :token
content-type: application/json


{
  "attribute": [
    {
      "name": "new-attr",
      "value": "...many characters here...."
    }
  ]
}
 

As you can see the name value pair is wrapped within an array called "attribute" in the JSON payload. Also I use POST, not PUT.

As far as I know it is not possible to update a single attribute by name. What I mean is if you want to add a single attribute name/value pair to a developer, you must write back a set of attributes, including all of the existing attributes you want to preserve, as well as the attribute you wish to add.

{
  "attribute": [
    {
      "name": "existing-attr-1",
      "value": "...characters representing the existing value...."
    },
    {
      "name": "existing-attr-2",
      "value": "another existing value...."
    },
    {
      "name": "new-attr",
      "value": "...up to 2kb here...."
    }

  ]
}

Can you try it this way?

I was just posting a snippet above, but I was using the full developer body as specified in the API link for PUT developer. It worked fine when the value was smaller but not when larger so it definitely seemed to be an issue with the value size.

I have tried the POST developer/attributes API method you mention above: https://apidocs.apigee.com/docs/developers/1/routes/organizations/%7Borg_name%7D/developers/%7Bdevel...

This allows to me put far larger attribute values in without breaking! This is great, it will be a workaround to use this endpoint instead of trying to use the PUT endpoint.

But I think perhaps there's a bug when setting large attribute values using the PUT developer endpoint, as it seems like it shouldn't fail with large values.


Thanks for your help and looking into this, it's much appreciated.

ah, I understand.

OK Yes, I agree, it sounds like a bug to me.

I'm glad you have a workaround.