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

[CURA-12067] The json-decorator-scope didn't set the user-agent yet. #962

Closed
wants to merge 1 commit into from

Conversation

rburema
Copy link
Member

@rburema rburema commented Aug 15, 2024

Add the header-dictionaries from base (which should've got the User-Agent set, at the very least in case we wrap around something that inherits from DefaultUserAgentScope, which is the only use-case I encountered) with the json-specific settings that are already in there. In order to prevent breaking the API, don't directly change the inheritance of the JsonDecoratorScope, but instead check for the existence of the header-dict in the base.

Add the header-dictionaries from base (which should've got the User-Agent set, at the very least in case we wrap around something that inherits from DefaultUserAgentScope, which is the only use-case I encountered) with the json-specific settings that are already in there. In order to prevent breaking the API, don't directly change the inheritance of the JsonDecoratorScope, but instead check for the existance of the header-dict in the base.

CURA-12067
Copy link
Contributor

@wawanbreton wawanbreton left a comment

Choose a reason for hiding this comment

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

I'm a bit confused by this fix, but it may be legitimate 😅

@@ -51,6 +51,10 @@ def __init__(self, base: HttpRequestScope) -> None:
"Content-Type": "application/json",
"Accept": "application/json"
}
# JsonDecorator probably _should_ have inherited from DefaultUserAgentScope in the first place.
# In order to prevent a break in the API by forcing that, just check if there are extra header specs needed.
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure it should actually inherit from DefaultUserAgentScope. You may want to use this decorator without the user-agent, or with a different one. Those decorators are, as I understood them, designed to be chained.
I would suggest to either:

  • Commit to your suggestion and force the inheritance
  • Commit to this new behavior and don't mention the inheritence in the comment

On the other hand, I'm overall surprised by this fix. The header_dict values should be applied in the requestHook method, both the ones from the base and the instance, so I don't see what good this does. I'm probably missing something.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, I missed that, sorry.
I think we should close this PR -- sorry 😓

@rburema rburema closed this Aug 15, 2024
@rburema rburema deleted the CURA-12067_set_useragent_for_json_scope branch August 15, 2024 13:08
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.

2 participants