Skip to content

refactor(jmespath_utils): deprecate extract_data_from_envelope in favor of query #4907

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

Merged
merged 4 commits into from
Aug 7, 2024

Conversation

n-k1
Copy link
Contributor

@n-k1 n-k1 commented Aug 7, 2024

Issue number: #4218

Summary

Changes

  • Added a query method in jmespath_utils/__init__.py with the same implementation as extract_data_from_envelope
  • Added a warning to extract_data_from_envelope and updated docstring

User experience

extract_data_from_envelope will continue to work with a deprecation warning and will be removed in the next major version. query will replace extract_data_from_envelope.

from aws_lambda_powertools.utilities.jmespath_utils import query
from aws_lambda_powertools.utilities.typing import LambdaContext


def handler(event: dict, context: LambdaContext) -> dict:
    payload = query(data=event, envelope="powertools_json(body)")
    customer_id = payload.get("customerId")  # now deserialized

    # also works for fetching and flattening deeply nested data
    some_data = query(data=event, envelope="deeply_nested[*].some_data[]")

    return {"customer_id": customer_id, "message": "success", "context": some_data, "statusCode": 200}

Checklist

If your change doesn't seem to apply, please leave them unchecked.

Is this a breaking change?

This is not a breaking change. extract_data_from_envelope will continue to work with a deprecation warning and will only be removed in the next major version.

RFC issue number:

Checklist:

  • Migration process documented
  • Implement warnings (if it can live side by side)

Acknowledgment

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.

@n-k1 n-k1 requested a review from a team August 7, 2024 13:29
@boring-cyborg boring-cyborg bot added documentation Improvements or additions to documentation jmespath JMESPath Functions utility logger tests labels Aug 7, 2024
@pull-request-size pull-request-size bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Aug 7, 2024
@github-actions github-actions bot added enhancement and removed documentation Improvements or additions to documentation labels Aug 7, 2024
@boring-cyborg boring-cyborg bot added the documentation Improvements or additions to documentation label Aug 7, 2024
@pull-request-size pull-request-size bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Aug 7, 2024
@github-actions github-actions bot removed the documentation Improvements or additions to documentation label Aug 7, 2024
@boring-cyborg boring-cyborg bot added the documentation Improvements or additions to documentation label Aug 7, 2024
@github-actions github-actions bot removed the documentation Improvements or additions to documentation label Aug 7, 2024
@boring-cyborg boring-cyborg bot added the documentation Improvements or additions to documentation label Aug 7, 2024
Copy link

sonarqubecloud bot commented Aug 7, 2024

Copy link
Contributor

@leandrodamascena leandrodamascena left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @n-k1! Thank you so much for taking the time to make this PR and having attention to details. I made a small change to it by adding a decorator to say that the method was deprecated and I changed the exception type.

This will be included in our major version v3!!

@leandrodamascena leandrodamascena changed the title refactor(jmespath_utils): deprecate extract_data_from_envelope in jmespath_utils and replace with query refactor(jmespath_utils): deprecate extract_data_from_envelope in favor of query Aug 7, 2024
@github-actions github-actions bot removed the documentation Improvements or additions to documentation label Aug 7, 2024
@boring-cyborg boring-cyborg bot added the documentation Improvements or additions to documentation label Aug 7, 2024
@github-actions github-actions bot removed the documentation Improvements or additions to documentation label Aug 7, 2024
@leandrodamascena leandrodamascena merged commit a4fdec0 into aws-powertools:v3 Aug 7, 2024
15 checks passed
Copy link

boring-cyborg bot commented Aug 7, 2024

Awesome work, congrats on your first merged pull request and thank you for helping improve everyone's experience!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement jmespath JMESPath Functions utility logger size/L Denotes a PR that changes 100-499 lines, ignoring generated files. tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tech debt: Review the name of the method extract_data_from_envelope in JMESPath Functions
2 participants