Skip to content

fix: replace mutable default arguments with None sentinels across backend - #2252

Open
harshadkhetpal wants to merge 2 commits into
Zipstack:mainfrom
harshadkhetpal:fix/mutable-default-arguments
Open

fix: replace mutable default arguments with None sentinels across backend#2252
harshadkhetpal wants to merge 2 commits into
Zipstack:mainfrom
harshadkhetpal:fix/mutable-default-arguments

Conversation

@harshadkhetpal

Copy link
Copy Markdown

Summary

Replaces the nine mutable default arguments in backend/ (ruff B006) with the standard None sentinel + normalization pattern. Python evaluates defaults once at import time, so = {} / = [] defaults are shared across every call — a latent cross-request state-leak hazard in long-lived Django workers:

  • api_v2/deployment_helper.pytag_names: list[str] = []
  • workflow_manager/endpoint_v2/queue_utils.pyconnector_settings: dict = {} ×2
  • workflow_manager/endpoint_v2/source.pyfile_hashes: dict[str, FileHash] = {}
  • workflow_manager/workflow_v2/dto.pykeys_to_remove: list[str] = []
  • workflow_manager/workflow_v2/views.pyhash_values_of_files: dict[str, FileHash] = {}
  • workflow_manager/workflow_v2/workflow_helper.py — same parameter ×3 (run_workflow, pipeline execution, execution-action dispatch)

Each signature becomes ... | None = None with a param = param or {} (or []) normalization as the first statement after the docstring, so all existing callers — including those passing None explicitly — get identical behavior.

Testing

python -m py_compile passes on all seven files; ruff check --select B006 on the touched paths goes from 9 errors to clean.

🤖 Generated with Claude Code

…kend

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@greptile-apps

greptile-apps Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Replaces shared mutable collection defaults with per-call None sentinels across backend workflow and deployment helpers.

  • Normalizes optional file-hash mappings throughout workflow orchestration and source enumeration.
  • Normalizes optional queue connector settings, deployment tags, and metadata-removal keys.
  • Preserves existing behavior for omitted and explicitly None arguments.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
backend/api_v2/deployment_helper.py Replaces the shared tag-name list default with an optional sentinel and per-call list.
backend/workflow_manager/endpoint_v2/queue_utils.py Replaces shared connector-settings defaults in both queue factory methods.
backend/workflow_manager/endpoint_v2/source.py Replaces the shared file-hash default used during source enumeration.
backend/workflow_manager/workflow_v2/dto.py Replaces the shared metadata-key removal list with a per-call list.
backend/workflow_manager/workflow_v2/views.py Normalizes the optional file-hash mapping at the workflow view boundary.
backend/workflow_manager/workflow_v2/workflow_helper.py Applies optional file-hash sentinels consistently across workflow execution entry points.

Reviews (2): Last reviewed commit: "[pre-commit.ci] auto fixes from pre-comm..." | Re-trigger Greptile

@sonarqubecloud

Copy link
Copy Markdown

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.

3 participants