Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing value field in update_api_key() #3764

Closed
lunarmint opened this issue Jun 28, 2023 · 3 comments
Closed

Missing value field in update_api_key() #3764

lunarmint opened this issue Jun 28, 2023 · 3 comments
Assignees
Labels
apigateway documentation This is a problem with documentation. service-api This issue is caused by the service API, not the SDK implementation.

Comments

@lunarmint
Copy link

Describe the issue

According to the documentation for update_api_key(), in response syntax, this method should return the value field that contains the API key. In reality, I did not see such field in the response. I'm not entirely sure if this is a documentation issue or a bug.

Links

https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/apigateway/client/update_api_key.html#APIGateway.Client.update_api_key

https://docs.aws.amazon.com/apigateway/latest/api/API_UpdateApiKey.html#API_UpdateApiKey_ResponseSyntax

@lunarmint lunarmint added documentation This is a problem with documentation. needs-triage This issue or PR still needs to be triaged. labels Jun 28, 2023
@tim-finnigan tim-finnigan self-assigned this Jun 29, 2023
@tim-finnigan
Copy link
Contributor

Hi @lunarmint thanks for reaching out. I would also expect to see the value field returned based on the documented Response Syntax. Which version of boto3 are you using? We recommend installing a recent version in order to stay up to date (the latest version is 1.26.163 per the CHANGELOG).

If you're still seeing an issue after updating that we would request the following for further investigation:

  1. A code snippet to reproduce the issue.
  2. Debug logs (with any sensitive info redacted) by adding boto3.set_stream_logger('') to your script.

@tim-finnigan tim-finnigan added response-requested Waiting on additional information or feedback. service-api This issue is caused by the service API, not the SDK implementation. apigateway and removed needs-triage This issue or PR still needs to be triaged. labels Jun 29, 2023
@lunarmint
Copy link
Author

@tim-finnigan Thank you for your response.

For more information, I'm currently on 1.29.163, but this issue has been affecting me since 1.29.157 when I first wrote the code.

Minimal reproducible code:

import json

import boto3

gateway_client = boto3.client("apigateway")


def lambda_handler(event, context):
    body = json.loads(event.get("body"))
    enabled = body.get("enabled")

    operations = []
    if enabled is not None:
        operations.append(
            {
                "op": "replace",
                "path": "/enabled",
                "value": enabled,
            }
        )

    api_key = gateway_client.update_api_key(
        apiKey="[REDACTED]",
        patchOperations=operations,
    )

    return json.dumps({"apiKey": api_key}, default=str)


if __name__ == "__main__":
    event = {
        "body": json.dumps(
            {
                "description": "Updated description",
                "enabled": "true",
            }
        )
    }
    print(lambda_handler(event, None))

Debug log:

2023-06-29 16:51:54,942 botocore.hooks [DEBUG] Changing event name from creating-client-class.iot-data to creating-client-class.iot-data-plane
2023-06-29 16:51:54,944 botocore.hooks [DEBUG] Changing event name from before-call.apigateway to before-call.api-gateway
2023-06-29 16:51:54,944 botocore.hooks [DEBUG] Changing event name from request-created.machinelearning.Predict to request-created.machine-learning.Predict
2023-06-29 16:51:54,945 botocore.hooks [DEBUG] Changing event name from before-parameter-build.autoscaling.CreateLaunchConfiguration to before-parameter-build.auto-scaling.CreateLaunchConfiguration
2023-06-29 16:51:54,946 botocore.hooks [DEBUG] Changing event name from before-parameter-build.route53 to before-parameter-build.route-53
2023-06-29 16:51:54,946 botocore.hooks [DEBUG] Changing event name from request-created.cloudsearchdomain.Search to request-created.cloudsearch-domain.Search
2023-06-29 16:51:54,947 botocore.hooks [DEBUG] Changing event name from docs.*.autoscaling.CreateLaunchConfiguration.complete-section to docs.*.auto-scaling.CreateLaunchConfiguration.complete-section
2023-06-29 16:51:54,949 botocore.hooks [DEBUG] Changing event name from before-parameter-build.logs.CreateExportTask to before-parameter-build.cloudwatch-logs.CreateExportTask
2023-06-29 16:51:54,949 botocore.hooks [DEBUG] Changing event name from docs.*.logs.CreateExportTask.complete-section to docs.*.cloudwatch-logs.CreateExportTask.complete-section
2023-06-29 16:51:54,949 botocore.hooks [DEBUG] Changing event name from before-parameter-build.cloudsearchdomain.Search to before-parameter-build.cloudsearch-domain.Search
2023-06-29 16:51:54,949 botocore.hooks [DEBUG] Changing event name from docs.*.cloudsearchdomain.Search.complete-section to docs.*.cloudsearch-domain.Search.complete-section
2023-06-29 16:51:54,953 botocore.utils [DEBUG] IMDS ENDPOINT: http://[REDACTED]/
2023-06-29 16:51:54,954 botocore.credentials [DEBUG] Looking for credentials via: env
2023-06-29 16:51:54,954 botocore.credentials [DEBUG] Looking for credentials via: assume-role
2023-06-29 16:51:54,954 botocore.credentials [DEBUG] Looking for credentials via: assume-role-with-web-identity
2023-06-29 16:51:54,954 botocore.credentials [DEBUG] Looking for credentials via: sso
2023-06-29 16:51:54,954 botocore.credentials [DEBUG] Looking for credentials via: shared-credentials-file
2023-06-29 16:51:54,955 botocore.credentials [INFO] Found credentials in shared credentials file: ~/.aws/credentials
2023-06-29 16:51:54,956 botocore.loaders [DEBUG] Loading JSON file: [REDACTED]\.venv\lib\site-packages\botocore\data\endpoints.json
2023-06-29 16:51:54,967 botocore.loaders [DEBUG] Loading JSON file: [REDACTED]\.venv\lib\site-packages\botocore\data\sdk-default-configuration.json
2023-06-29 16:51:54,967 botocore.hooks [DEBUG] Event choose-service-name: calling handler <function handle_service_name_alias at 0x0000019FB4C8D0D8>
2023-06-29 16:51:54,993 botocore.loaders [DEBUG] Loading JSON file: [REDACTED]\.venv\lib\site-packages\botocore\data\apigateway\2015-07-09\service-2.json
2023-06-29 16:51:55,029 botocore.loaders [DEBUG] Loading JSON file: [REDACTED]\.venv\lib\site-packages\botocore\data\apigateway\2015-07-09\endpoint-rule-set-1.json.gz
2023-06-29 16:51:55,029 botocore.loaders [DEBUG] Loading JSON file: [REDACTED]\.venv\lib\site-packages\botocore\data\partitions.json
2023-06-29 16:51:55,032 botocore.hooks [DEBUG] Event creating-client-class.api-gateway: calling handler <function add_generate_presigned_url at 0x0000019FB4C12318>
2023-06-29 16:51:55,033 botocore.endpoint [DEBUG] Setting apigateway timeout as (60, 60)
2023-06-29 16:51:55,034 botocore.loaders [DEBUG] Loading JSON file: [REDACTED]\.venv\lib\site-packages\botocore\data\_retry.json
2023-06-29 16:51:55,034 botocore.client [DEBUG] Registering retry handlers for service: apigateway
2023-06-29 16:51:55,035 botocore.hooks [DEBUG] Event before-parameter-build.api-gateway.UpdateApiKey: calling handler <function generate_idempotent_uuid at 0x0000019FB4CDC0D8>
2023-06-29 16:51:55,035 botocore.regions [DEBUG] Calling endpoint provider with parameters: {'Region': 'us-east-1', 'UseDualStack': False, 'UseFIPS': False}
2023-06-29 16:51:55,035 botocore.regions [DEBUG] Endpoint provider result: https://apigateway.us-east-1.amazonaws.com
2023-06-29 16:51:55,036 botocore.hooks [DEBUG] Event before-call.api-gateway.UpdateApiKey: calling handler <function add_accept_header at 0x0000019FB4CD9168>
2023-06-29 16:51:55,036 botocore.hooks [DEBUG] Event before-call.api-gateway.UpdateApiKey: calling handler <function add_recursion_detection_header at 0x0000019FB4CCFE58>
2023-06-29 16:51:55,036 botocore.hooks [DEBUG] Event before-call.api-gateway.UpdateApiKey: calling handler <function inject_api_version_header_if_needed at 0x0000019FB4CD9948>
2023-06-29 16:51:55,036 botocore.endpoint [DEBUG] Making request for OperationModel(name=UpdateApiKey) with params: {'url_path': '/apikeys/[REDACTED]', 'query_string': {}, 'method': 'PATCH', 'headers': {'Content-Type': 'application/json', 'User-Agent': 'Boto3/1.26.163 Python/3.7.14 Windows/10 Botocore/1.29.163', 'Accept': 'application/json'}, 'body': b'{"patchOperations": [{"op": "replace", "path": "/description", "value": "Updated description"}, {"op": "replace", "path": "/enabled", "value": "true"}]}', 'url': 'https://apigateway.us-east-1.amazonaws.com/apikeys/[REDACTED]', 'context': {'client_region': 'us-east-1', 'client_config': <botocore.config.Config object at 0x0000019FB54C10C8>, 'has_streaming_input': False, 'auth_type': None}}
2023-06-29 16:51:55,036 botocore.hooks [DEBUG] Event request-created.api-gateway.UpdateApiKey: calling handler <bound method RequestSigner.handler of <botocore.signers.RequestSigner object at 0x0000019FB54C1088>>
2023-06-29 16:51:55,036 botocore.hooks [DEBUG] Event choose-signer.api-gateway.UpdateApiKey: calling handler <function set_operation_specific_signer at 0x0000019FB4CD3F78>
2023-06-29 16:51:55,038 botocore.auth [DEBUG] Calculating signature using v4 auth.
2023-06-29 16:51:55,038 botocore.auth [DEBUG] CanonicalRequest:
PATCH
/apikeys/[REDACTED]

accept:application/json
content-type:application/json
host:apigateway.us-east-1.amazonaws.com
x-amz-date:20230629T205155Z

accept;content-type;host;x-amz-date
[REDACTED]
2023-06-29 16:51:55,038 botocore.auth [DEBUG] StringToSign:
AWS4-HMAC-SHA256
20230629T205155Z
20230629/us-east-1/apigateway/aws4_request
[REDACTED]
2023-06-29 16:51:55,038 botocore.auth [DEBUG] Signature:
[REDACTED]
2023-06-29 16:51:55,038 botocore.hooks [DEBUG] Event request-created.api-gateway.UpdateApiKey: calling handler <function add_retry_headers at 0x0000019FB4CDE048>
2023-06-29 16:51:55,038 botocore.endpoint [DEBUG] Sending http request: <AWSPreparedRequest stream_output=False, method=PATCH, url=https://apigateway.us-east-1.amazonaws.com/apikeys/[REDACTED], headers={'Content-Type': b'application/json', 'User-Agent': b'Boto3/1.26.163 Python/3.7.14 Windows/10 Botocore/1.29.163', 'Accept': b'application/json', 'X-Amz-Date': b'20230629T205155Z', 'Authorization': b'AWS4-HMAC-SHA256 Credential=[REDACTED]/20230629/us-east-1/apigateway/aws4_request, SignedHeaders=accept;content-type;host;x-amz-date, Signature=[REDACTED]', 'amz-sdk-invocation-id': b'[REDACTED]', 'amz-sdk-request': b'attempt=1', 'Content-Length': '152'}>
2023-06-29 16:51:55,039 botocore.httpsession [DEBUG] Certificate path: [REDACTED]\.venv\lib\site-packages\certifi\cacert.pem
2023-06-29 16:51:55,039 urllib3.connectionpool [DEBUG] Starting new HTTPS connection (1): apigateway.us-east-1.amazonaws.com:443
2023-06-29 16:51:55,486 urllib3.connectionpool [DEBUG] https://apigateway.us-east-1.amazonaws.com:443 "PATCH /apikeys/[REDACTED] HTTP/1.1" 200 177
2023-06-29 16:51:55,486 botocore.parsers [DEBUG] Response headers: {'Date': 'Thu, 29 Jun 2023 20:51:53 GMT', 'Content-Type': 'application/json', 'Content-Length': '177', 'Connection': 'keep-alive', 'x-amzn-RequestId': '[REDACTED]', 'x-amz-apigw-id': '[REDACTED]'}
2023-06-29 16:51:55,486 botocore.parsers [DEBUG] Response body:
b'{"createdDate":1687973992,"description":"Updated description","enabled":true,"id":"[REDACTED]","lastUpdatedDate":1688071913,"name":"[REDACTED]","stageKeys":[],"tags":{}}\n'
2023-06-29 16:51:55,486 botocore.hooks [DEBUG] Event needs-retry.api-gateway.UpdateApiKey: calling handler <botocore.retryhandler.RetryHandler object at 0x0000019FB54D6548>
2023-06-29 16:51:55,486 botocore.retryhandler [DEBUG] No retry needed.

@github-actions github-actions bot removed the response-requested Waiting on additional information or feedback. label Jun 29, 2023
@tim-finnigan tim-finnigan added the investigating This issue is being investigated and/or work is in progress to resolve the issue. label Jul 10, 2023
@tim-finnigan
Copy link
Contributor

Thanks for following up here and sharing your logs — upon revisiting this I also did not see value returned as I would have expected per the documentation. Since this issue relates to the UpdateApiKey API, I created a new issue here in our cross-SDK repository because service APIs are used across SDKs: aws/aws-sdk#560.

I escalated this to the API Gateway team for more info and will update that issue when we know more. Thanks again for reporting this and please refer to that issue for updates going forward.

@tim-finnigan tim-finnigan removed the investigating This issue is being investigated and/or work is in progress to resolve the issue. label Jul 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
apigateway documentation This is a problem with documentation. service-api This issue is caused by the service API, not the SDK implementation.
Projects
None yet
Development

No branches or pull requests

2 participants