Skip to content

fix: preserve app attributes when generating a new key#718

Open
saiflayouni wants to merge 2 commits into
apigee:mainfrom
saiflayouni:fix/genkey-preserves-attributes
Open

fix: preserve app attributes when generating a new key#718
saiflayouni wants to merge 2 commits into
apigee:mainfrom
saiflayouni:fix/genkey-preserves-attributes

Conversation

@saiflayouni

Copy link
Copy Markdown

Summary

  • GenerateKey was POSTing to /developers/{dev}/apps/{name} without including the app's existing attributes in the payload
  • The Apigee API treats this endpoint as an app update in addition to key generation, so any field absent from the request body gets cleared
  • Fix fetches the current app before the POST and re-includes its attributes in the payload

Fixes #651

Test plan

  • Updated TestGenerateKey in internal/client/apps/apps_test.go to assert that app attributes are present in the response after key generation
  • Run against a real Apigee org: go test -v -run TestGenerateKey ./...

The Apigee POST /developers/{dev}/apps/{name} endpoint generates a new
key but also updates the app, clearing any field absent from the request
body. GenerateKey did not include existing attributes in its payload, so
all app attributes were wiped on every genkey call.

Fix by fetching the current app before the POST and re-including its
attributes in the payload.

Fixes apigee#651
…est arg count

Replace unsafe string-concatenation for attribute JSON with json.Marshal,
which correctly handles any special characters in attribute names/values.

Also fix pre-existing test breakage in keys_test.go where ManageKey was
called with 4 arguments instead of the required 5.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Using apigeecli apps genkey removes all App attributes

1 participant