Skip to content

πŸ—οΈ Architect: Fix hidden mutable state bug in ParamMixin._resolve_params#751

Merged
fderuiter merged 1 commit intomainfrom
architect-fix-param-mutation-17841403166980914882
Apr 1, 2026
Merged

πŸ—οΈ Architect: Fix hidden mutable state bug in ParamMixin._resolve_params#751
fderuiter merged 1 commit intomainfrom
architect-fix-param-mutation-17841403166980914882

Conversation

@fderuiter
Copy link
Copy Markdown
Owner

πŸ—οΈ Refactor Candidate: Mutable Dictionary Argument Bug in Param Resolution

The Smell:
In src/imednet/core/endpoint/mixins/params.py, the _resolve_params method receives an extra_params: Optional[Dict[str, Any]] argument and calls extra_params.update(special_params). This unintentionally modifies the dictionary passed by the caller in place, creating an implicit side effect and violating the rule against hidden mutable state.

The Fix:
I applied the "Defensive Copying" strategy. By explicitly assigning extra_params = extra_params.copy() before updating it, we ensure that the caller's dictionary is left completely intact.

The Code:

        if special_params:
            if extra_params is None:
                extra_params = {}
            else:
                extra_params = extra_params.copy()
            extra_params.update(special_params)

Verification:

  • Types are strict (No Any introduced)
  • Sync/Async parity maintained
  • No logic changes, only structural safety

Architect's Advice:

  • "If a function modifies an argument, the caller is no longer safe to use it. A defensive copy is cheaper than a mysterious bug in production."

PR created automatically by Jules for task 17841403166980914882 started by @fderuiter

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown
Contributor

πŸ‘‹ Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a πŸ‘€ emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@fderuiter fderuiter marked this pull request as ready for review April 1, 2026 16:44
@fderuiter fderuiter merged commit 2b632f1 into main Apr 1, 2026
13 checks passed
@fderuiter fderuiter deleted the architect-fix-param-mutation-17841403166980914882 branch April 1, 2026 16:44
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