Skip to content

Avoid mutating passed-in request data#982

Open
LeMyst wants to merge 1 commit into
masterfrom
avoid-mutating-data
Open

Avoid mutating passed-in request data#982
LeMyst wants to merge 1 commit into
masterfrom
avoid-mutating-data

Conversation

@LeMyst

@LeMyst LeMyst commented Jun 6, 2026

Copy link
Copy Markdown
Owner

Convert and copy incoming request payloads to prevent accidental mutation of caller-provided mappings. In mediawiki_api_call, kwargs['data'] is wrapped with dict(...) so updates (like adding format) work for non-dict mappings and don't modify the original. In mediawiki_api_call_helper, data is shallow-copied before use to avoid side effects when modifying the payload. This makes API helper functions safer when callers pass in shared or immutable mapping types.

Convert and copy incoming request payloads to prevent accidental mutation of caller-provided mappings. In mediawiki_api_call, kwargs['data'] is wrapped with dict(...) so updates (like adding format) work for non-dict mappings and don't modify the original. In mediawiki_api_call_helper, data is shallow-copied before use to avoid side effects when modifying the payload. This makes API helper functions safer when callers pass in shared or immutable mapping types.
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.

1 participant