Skip to content

Fix mutable default argument bug in service retrieve methods#98

Closed
zhibindai26 wants to merge 3 commits intomainfrom
fix/mutable-default-params
Closed

Fix mutable default argument bug in service retrieve methods#98
zhibindai26 wants to merge 3 commits intomainfrom
fix/mutable-default-params

Conversation

@zhibindai26
Copy link
Copy Markdown
Contributor

@zhibindai26 zhibindai26 commented Apr 14, 2026

Summary

  • Fix mutable default argument (params={}) in PortfolioSizeService.retrieve(), PropertyTypeService.retrieve(), and PropertyEventsService.retrieve()
  • The shared default dict caused portfolio_size and property_type values to silently leak into subsequent calls that omitted the params argument
  • Changed to idiomatic params=None with if params is None: params = {} guard in the function body
  • Changed from deprecated config to ConfigDict in pydantic model configs

Test plan

  • All 77 existing tests pass
  • Lint passes (ruff check + ruff format --check)
  • Verify that consecutive .retrieve() calls with and without portfolio_size/property_type no longer carry over stale filter values

🤖 Generated with Claude Code

zhibindai26 and others added 3 commits April 14, 2026 10:45
The `params: Mapping[str, Any] | None = {}` default was a single dict
shared across all calls. Once mutated (e.g. by passing portfolio_size
or property_type), the stale value persisted in subsequent calls that
omitted params. Changed to `dict[str, Any] | None = None` with
explicit `if params is None: params = {}` in the function body.

Fixed in: PortfolioSizeService, PropertyTypeService, PropertyEventsService.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@zhibindai26 zhibindai26 deleted the fix/mutable-default-params branch April 14, 2026 16:18
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