-
Notifications
You must be signed in to change notification settings - Fork 25
Move initialized action callable to private field #145
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
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
When we included the initialized callable in a public model field, we ran into a bug where `jsonable_encoder` couldn't serialzie an action with an initalized `requests.Session` object. In this commit, we move the initialized caller to a private field so that it's excluded during serialization.
leplatrem
reviewed
Jul 25, 2022
- change name - caller takes and returns a payload
Pydantic does not include properties in the serialized object, which is exactly what we need in this case. This commit also changes the callable name to `caller` so we avoid mirroring the built-in `callable` function
leplatrem
approved these changes
Jul 26, 2022
leplatrem
added a commit
that referenced
this pull request
Aug 1, 2022
**Bug Fixes** - Retrieve comments from the API if they are private (fixes #154) (#163) **New Features** - Show 'Bug XXXX' instead of Bugzilla Ticket in Jira link (#159) - Add Jira details to log context (#157) - Retry Jira and Bugzilla on error (fixes #33) (#152) - Add counter and timer for action execution (fixes #23, #62, #160, #164) - Tweak logging (log `500` requests), other logging-adjacent tweaks (#161) **Configuration** - Use JB instead of OSS in config.prod.yaml and config.nonprod.yaml (#151, #153) - Add local config for tests (fixes #121) (#138) **Documentation** - Start (naive) troubleshooting section in README (#156) **Internal Changes** - Run app as a single uvicorn process (fixes #133) (#162) - Move initialized action callable to private field (#145) - Do not sleep in retry tests (#158) - Bump sentry-sdk from 1.8.0 to 1.9.0 (#167) - Bump yamllint from 1.26.3 to 1.27.1 (#166) - Bump atlassian-python-api from 3.20.1 to 3.25.0 (#149) - Bump dockerflow from 2022.1.0 to 2022.7.0 (#147) - Bump sentry-sdk from 1.7.2 to 1.8.0 (#146) - Bump detect-secrets from 1.2.0 to 1.3.0 (#148) - Bump mypy from 0.910 to 0.971 (#150)
Merged
leplatrem
added a commit
that referenced
this pull request
Aug 1, 2022
**Bug Fixes** - Retrieve comments from the API if they are private (fixes #154) (#163) **New Features** - Show 'Bug XXXX' instead of Bugzilla Ticket in Jira link (#159) - Add Jira details to log context (#157) - Retry Jira and Bugzilla on error (fixes #33) (#152) - Add counter and timer for action execution (fixes #23, #62, #160, #164) - Tweak logging (log `500` requests), other logging-adjacent tweaks (#161) **Configuration** - Use JB instead of OSS in config.prod.yaml and config.nonprod.yaml (#151, #153) - Add local config for tests (fixes #121) (#138) **Documentation** - Start (naive) troubleshooting section in README (#156) **Internal Changes** - Run app as a single uvicorn process (fixes #133) (#162) - Move initialized action callable to private field (#145) - Do not sleep in retry tests (#158) - Bump sentry-sdk from 1.8.0 to 1.9.0 (#167) - Bump yamllint from 1.26.3 to 1.27.1 (#166) - Bump atlassian-python-api from 3.20.1 to 3.25.0 (#149) - Bump dockerflow from 2022.1.0 to 2022.7.0 (#147) - Bump sentry-sdk from 1.7.2 to 1.8.0 (#146) - Bump detect-secrets from 1.2.0 to 1.3.0 (#148) - Bump mypy from 0.910 to 0.971 (#150) - Bump fastapi from 0.73.0 to 0.79.0 (#168)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When we included the callable in a public model field, we ran into a bug (#136 and #137) where
jsonable_encodercouldn't serialize an action with an initializedrequests.Sessionobject.Here's how I recreated the error we saw:
For some reason, excluding the
callablefield withConfigdidn't seem to fix the bug. So instead, in this PR we move the callable to a private field with Pydantic'sPrivateAttr.We also add a test case as a regression test for the bug we observed.
This seems like more of a bug with
jsonable_encoder, but it's probably good to remove the callable from the dict representation of the model anyway.