chore: add allow_inf_nan=False to all remaining ConfigDict declarations#943
chore: add allow_inf_nan=False to all remaining ConfigDict declarations#943
Conversation
Closes #913 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
📜 Recent review details⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
🧰 Additional context used📓 Path-based instructions (2)!(src/synthorg/observability/setup.py|src/synthorg/observability/sinks.py)📄 CodeRabbit inference engine (CLAUDE.md)
Files:
docs/**/*.md📄 CodeRabbit inference engine (CLAUDE.md)
Files:
🧠 Learnings (12)📓 Common learnings📚 Learning: 2026-03-31T08:35:07.813ZApplied to files:
📚 Learning: 2026-03-17T22:08:13.456ZApplied to files:
📚 Learning: 2026-03-20T21:44:04.528ZApplied to files:
📚 Learning: 2026-03-15T19:14:27.144ZApplied to files:
📚 Learning: 2026-03-15T18:38:44.202ZApplied to files:
📚 Learning: 2026-03-20T08:28:32.845ZApplied to files:
📚 Learning: 2026-03-31T08:35:07.813ZApplied to files:
📚 Learning: 2026-03-15T18:38:44.202ZApplied to files:
📚 Learning: 2026-03-17T22:08:13.456ZApplied to files:
📚 Learning: 2026-03-15T19:14:27.144ZApplied to files:
📚 Learning: 2026-03-15T19:14:27.144ZApplied to files:
🔇 Additional comments (1)
WalkthroughThis PR adds Suggested labels
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Snapshot WarningsEnsure that dependencies are being submitted on PR branches. Re-running this action after a short time may resolve the issue. See the documentation for more information and troubleshooting advice. Scanned FilesNone |
There was a problem hiding this comment.
Code Review
This pull request implements a global update to Pydantic model configurations by adding allow_inf_nan=False to the ConfigDict of numerous BaseModel subclasses. This change enhances data validation by explicitly prohibiting the use of infinity and NaN values across various modules, including API, core engine, security, and communication subsystems. I have no feedback to provide.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/synthorg/engine/decomposition/llm.py`:
- Line 64: The ConfigDict instantiation uses an invalid parameter allow_inf_nan;
remove allow_inf_nan from model_config = ConfigDict(frozen=True) and instead
enforce no-inf/nan at field-level by updating the temperature field (in the
relevant Pydantic model/class) to use Field(allow_inf_nan=False) or change its
type to FiniteFloat; make sure to keep ConfigDict(frozen=True) and adjust the
temperature field definition accordingly.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: c85eaf4d-1518-4f87-b108-ed57511de3bc
📒 Files selected for processing (92)
src/synthorg/api/auth/config.pysrc/synthorg/api/auth/controller.pysrc/synthorg/api/auth/models.pysrc/synthorg/api/auth/ticket_store.pysrc/synthorg/api/config.pysrc/synthorg/api/controllers/approvals.pysrc/synthorg/api/controllers/autonomy.pysrc/synthorg/api/controllers/budget.pysrc/synthorg/api/controllers/health.pysrc/synthorg/api/controllers/meetings.pysrc/synthorg/api/controllers/setup_models.pysrc/synthorg/api/controllers/users.pysrc/synthorg/api/dto_discovery.pysrc/synthorg/api/ws_models.pysrc/synthorg/budget/config.pysrc/synthorg/budget/coordination_config.pysrc/synthorg/budget/coordination_metrics.pysrc/synthorg/budget/hierarchy.pysrc/synthorg/budget/spending_summary.pysrc/synthorg/communication/channel.pysrc/synthorg/communication/config.pysrc/synthorg/communication/conflict_resolution/config.pysrc/synthorg/communication/conflict_resolution/models.pysrc/synthorg/communication/delegation/authority.pysrc/synthorg/communication/dispatcher.pysrc/synthorg/communication/handler.pysrc/synthorg/communication/loop_prevention/models.pysrc/synthorg/communication/meeting/config.pysrc/synthorg/communication/meeting/models.pysrc/synthorg/communication/message.pysrc/synthorg/communication/subscription.pysrc/synthorg/config/schema.pysrc/synthorg/core/agent.pysrc/synthorg/core/approval.pysrc/synthorg/core/artifact.pysrc/synthorg/core/company.pysrc/synthorg/core/project.pysrc/synthorg/core/role.pysrc/synthorg/engine/agent_state.pysrc/synthorg/engine/approval_gate_models.pysrc/synthorg/engine/checkpoint/models.pysrc/synthorg/engine/classification/models.pysrc/synthorg/engine/compaction/models.pysrc/synthorg/engine/context.pysrc/synthorg/engine/context_budget.pysrc/synthorg/engine/coordination/config.pysrc/synthorg/engine/coordination/dispatchers.pysrc/synthorg/engine/coordination/models.pysrc/synthorg/engine/coordination/section_config.pysrc/synthorg/engine/decomposition/llm.pysrc/synthorg/engine/decomposition/models.pysrc/synthorg/engine/hybrid_models.pysrc/synthorg/engine/loop_protocol.pysrc/synthorg/engine/loop_selector.pysrc/synthorg/engine/parallel_models.pysrc/synthorg/engine/plan_models.pysrc/synthorg/engine/prompt.pysrc/synthorg/engine/recovery.pysrc/synthorg/engine/routing/models.pysrc/synthorg/engine/run_result.pysrc/synthorg/engine/stagnation/models.pysrc/synthorg/engine/task_engine_models.pysrc/synthorg/engine/task_execution.pysrc/synthorg/engine/workspace/config.pysrc/synthorg/engine/workspace/models.pysrc/synthorg/hr/promotion/config.pysrc/synthorg/hr/promotion/models.pysrc/synthorg/observability/config.pysrc/synthorg/persistence/config.pysrc/synthorg/providers/models.pysrc/synthorg/providers/probing.pysrc/synthorg/providers/routing/models.pysrc/synthorg/security/autonomy/models.pysrc/synthorg/security/config.pysrc/synthorg/security/models.pysrc/synthorg/security/timeout/config.pysrc/synthorg/security/timeout/models.pysrc/synthorg/security/timeout/parked_context.pysrc/synthorg/security/trust/config.pysrc/synthorg/security/trust/models.pysrc/synthorg/settings/models.pysrc/synthorg/templates/model_matcher.pysrc/synthorg/templates/model_requirements.pysrc/synthorg/templates/schema.pysrc/synthorg/tools/base.pysrc/synthorg/tools/git_url_validator.pysrc/synthorg/tools/mcp/config.pysrc/synthorg/tools/mcp/models.pysrc/synthorg/tools/sandbox/config.pysrc/synthorg/tools/sandbox/docker_config.pysrc/synthorg/tools/sandbox/result.pysrc/synthorg/tools/sandbox/sandboxing_config.py
| """ | ||
|
|
||
| model_config = ConfigDict(frozen=True) | ||
| model_config = ConfigDict(frozen=True, allow_inf_nan=False) |
There was a problem hiding this comment.
🧩 Analysis chain
🌐 Web query:
Does Pydantic v2.12.5 support allow_inf_nan as a ConfigDict parameter? What is the correct way to reject NaN and Inf values in Pydantic v2?
💡 Result:
No, Pydantic v2.12.5 does not support allow_inf_nan as a ConfigDict (model_config) parameter. The official documentation lists allow_inf_nan as a field-level parameter for numeric fields (float, Decimal) via Field, confloat, etc., and as a metadata class AllowInfNan. ConfigDict supports ser_json_inf_nan for serialization behavior, but not allow_inf_nan for validation. The correct way to reject NaN and Inf values in Pydantic v2 is to use field constraints: 1. For plain float fields, use Field(allow_inf_nan=False) or confloat(allow_inf_nan=False): from pydantic import BaseModel, Field, confloat class Model(BaseModel): value: float = Field(allow_inf_nan=False) # or: value: confloat(allow_inf_nan=False) 2. Use built-in types like FiniteFloat which rejects NaN/Inf: from pydantic import BaseModel, FiniteFloat class Model(BaseModel): value: FiniteFloat This raises ValidationError for NaN, Inf, -Inf. Confirmed across Pydantic v2 docs (including latest for v2.12.5), GitHub issues (#7296), and API references. Floats allow NaN/Inf by default unless explicitly rejected at field level.
Citations:
- 1: https://docs.pydantic.dev/latest/api/config/
- 2: https://docs.pydantic.dev/2.0/usage/types/number_types/
- 3: https://docs.pydantic.dev/2.1/api/fields/
- 4: https://docs.pydantic.dev/2.0/api/types/
- 5: https://docs.pydantic.dev/latest/api/standard_library_types/
- 6: https://docs.pydantic.dev/2.3/usage/types/number_types/
- 7: https://docs.pydantic.dev/latest/api/fields
- 8: Default of
allow_inf_nanforDecimalandfloatare inconsistent pydantic/pydantic#7296 - 9: https://stackoverflow.com/questions/72472526/how-to-filter-out-nan-by-pydantic
Use field-level allow_inf_nan=False constraint instead of ConfigDict parameter.
allow_inf_nan is not a valid ConfigDict parameter in Pydantic v2.12.5—it is a field-level constraint only. Remove it from ConfigDict and apply directly to the temperature field using Field(allow_inf_nan=False), or use the FiniteFloat type instead.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/synthorg/engine/decomposition/llm.py` at line 64, The ConfigDict
instantiation uses an invalid parameter allow_inf_nan; remove allow_inf_nan from
model_config = ConfigDict(frozen=True) and instead enforce no-inf/nan at
field-level by updating the temperature field (in the relevant Pydantic
model/class) to use Field(allow_inf_nan=False) or change its type to
FiniteFloat; make sure to keep ConfigDict(frozen=True) and adjust the
temperature field definition accordingly.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #943 +/- ##
==========================================
- Coverage 92.15% 92.15% -0.01%
==========================================
Files 600 600
Lines 32052 32052
Branches 3115 3115
==========================================
- Hits 29537 29536 -1
Misses 1985 1985
- Partials 530 531 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
🤖 I have created a release *beep* *boop* --- ## [0.5.3](v0.5.2...v0.5.3) (2026-03-31) ### Features * implement artifact and project persistence ([#947](#947)) ([6dea87a](6dea87a)) ### Maintenance * add allow_inf_nan=False to all remaining ConfigDict declarations ([#943](#943)) ([cd7bbca](cd7bbca)) * audit full web dashboard for hardcoded design token violations ([#944](#944)) ([a1322cd](a1322cd)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
Summary
allow_inf_nan=Falseto all 260 remainingConfigDictdeclarations across 92 files insrc/synthorg/ConfigDictdeclarations in the codebase now consistently rejectNaN/Infin numeric fields at validation timeDetails
PR #911 established the
allow_inf_nan=Falseconvention and applied it toTaskandAcceptanceCriterion. This PR completes the rollout to all remaining models across: api/, budget/, communication/, config/, core/, engine/, hr/, memory/ (already done), observability/, persistence/, providers/, security/, settings/, templates/, and tools/.Four patterns were updated:
ConfigDict(frozen=True)(240 declarations)ConfigDict(frozen=True, extra="forbid")(18 declarations)ConfigDict(frozen=True, arbitrary_types_allowed=True)(1 declaration)ConfigDict(frozen=True, populate_by_name=True)(1 declaration)Test plan
uv run ruff check src/ tests/-- all checks passeduv run ruff format src/ tests/-- all files already formatteduv run mypy src/ tests/-- no issues in 1,250 filesuv run python -m pytest tests/ -n auto-- 11,259 passed, 9 skippedCloses #913
🤖 Generated with Claude Code