-
Notifications
You must be signed in to change notification settings - Fork 34
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Version: apigeecli version 2.4.0 date: 2024-08-21T16:56:04Z [commit: e96358f]
When running the command:
apigeecli environments debugmask set --token <token> --org <organisation> --env <environment> --mask-file debugmask.jsonwith the contents of the debugmask.json being:
{
"variables": [
"request.header.x-api-key",
"request.header.x-apikey"
]
}(taken from the samples/debugmask.json file in the repository), the following error is thrown by apigeecli:
Error: json: cannot unmarshal array into Go value of type string
It seems that this happens because the tool is trying to deserialize the JSON into a string-string key-value pair, as seen in the following part of the code: https://github.com/apigee/apigeecli/blob/main/internal/client/env/debugmask.go#L35-L39.
When I modify the JSON file to specify a string key-value pair like this:
{
"variables": "request.header.x-apikey"
}the deserialization error disappears, but the command still fails, returning a 404 error page from Google:
Error: Not found - the server cannot find the requested resource
Reproduction Steps
- Run the following command:
apigeecli environments debugmask set --token <token> --org <organisation> --env <environment> --mask-file debugmask.jsonWith debugmask.json containing:
{
"variables": [
"request.header.x-api-key",
"request.header.x-apikey"
]
}- The following error occurs:
Error: json: cannot unmarshal array into Go value of type string
- After changing the debugmask.json to a string:
{
"variables": "request.header.x-apikey"
}- The command returns:
Error 404 (Not Found)
Additional Information
- When running apigeecli in debug mode, it shows that a
POSTrequest is sent to the API:
APIGEECLI_DEBUG=true apigeecli environments debugmask set --token <token> --org example-org --env example-env --mask-file debugmask.jsonDebug output:
DEBUG: Connecting to: POST - https://apigee.googleapis.com/v1/organizations/example-org/environments/example-env/debugmask
- However, according to the official Apigee documentation, a PATCH request should be used instead: https://cloud.google.com/apigee/docs/reference/apis/apigee/rest/v1/organizations.environments/updateDebugmask
- Additionally, the expected request body format is not a string key-value pair as the current implementation suggests. The correct request body structure is outlined in the documentation: https://cloud.google.com/apigee/docs/reference/apis/apigee/rest/v1/DebugMask
Suggested Fix
- Change the HTTP method from
POSTtoPATCHas per the official documentation. - Update the JSON handling logic to follow the correct structure from the documentation, where arrays like
"variables"should be supported rather than string key-value pairs.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working