Skip to content

Fix #226: resolve Pydantic v1 recursion in RunDetails instantiation - #237

Open
Ashutosh Mishra (Ashut0sh-mishra) wants to merge 2 commits into
microsoft:mainfrom
Ashut0sh-mishra:fix/issue-226-pydantic-recursion
Open

Fix #226: resolve Pydantic v1 recursion in RunDetails instantiation#237
Ashutosh Mishra (Ashut0sh-mishra) wants to merge 2 commits into
microsoft:mainfrom
Ashut0sh-mishra:fix/issue-226-pydantic-recursion

Conversation

@Ashut0sh-mishra

Copy link
Copy Markdown

Summary

Fixes #226

Problem

The FarmVibes.AI Python client throws a RecursionError
when triggering workflows on the remote AKS cluster.

Root cause: RunDetails() was triggering recursive init
wrapping in Pydantic v1 when instantiated repeatedly in
server.py. Each instantiation wrapped the previous init,
causing a stack overflow on repeated workflow calls.

Fix

Applied the same fix pattern already present in
orchestrator.py (by the original authors) — cached an empty
RunDetails instance using asdict() and copy() instead of
creating a new RunDetails() on every call, avoiding the
recursive Pydantic wrapping entirely.

Files Changed

  • src/vibe_server/vibe_server/server.py (6 lines)

Validation

  • Identical pattern to existing fix in orchestrator.py
  • No other production code has the same bug pattern
  • No compile or lint errors in the changed file
  • Full integration testing handled by CI/CD on PR creation

Co-authors

Co-authored-by: nik464 nikhil18chaudhary@gmail.com

@Ashut0sh-mishra

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

@Ashut0sh-mishra
Ashutosh Mishra (Ashut0sh-mishra) force-pushed the fix/issue-226-pydantic-recursion branch 3 times, most recently from d8dbb6c to 288014d Compare April 13, 2026 10:42
…tiation

RunDetails() was triggering recursive __init__ wrapping in Pydantic v1
when instantiated repeatedly in server.py. Applied the same fix pattern
already used in orchestrator.py by the original authors.
Fixes microsoft#226
Co-authored-by: nik464 <nikhil18chaudhary@gmail.com>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current RunDetails cache does not fix the recursion: DataclassJSONEncoder repeatedly decorates an already decorated RunConfig and cumulatively wraps its initializer. The root fix is to reuse the class-owned pydantic_model. I opened a minimal patch with a 2,000-round regression test against your branch at Ashut0sh-mishra#1. Please merge that PR; upstream #237 will update automatically while preserving your attribution, and we can review the corrected head.

@Ashut0sh-mishra

Copy link
Copy Markdown
Author

Addressed review feedback on this PR with the root fix and regression coverage.

Changes made:

  • Fixed repeated pydantic dataclass decoration in DataclassJSONEncoder by reusing the class-owned pydantic_model when present, and only decorating when absent.
  • Removed the RunDetails caching workaround in server.py and restored standard RunDetails() construction.
  • Added a focused regression test (2,000 rounds) to validate repeated RunConfig serialize/deserialize cycles do not re-wrap initialization.

Updated files:

  • src/vibe_core/vibe_core/data/json_converter.py
  • src/vibe_server/vibe_server/server.py
  • src/vibe_core/tests/test_json_converter.py

Notes on validation:

  • Static diagnostics and py_compile are clean for all changed files.
  • Local pytest execution for the new test is blocked in this environment by an existing dependency mismatch (pydantic import path for ModelMetaclass), which is unrelated to this patch and should be validated in CI.

@Ashut0sh-mishra

Copy link
Copy Markdown
Author

Renato L. de F. Cunha (@renatolfc) pushed requested fixes to this branch (root pydantic_model reuse + regression test). Could you please re-review when you have time?

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.

RecursionError occurs intermittently when triggering workflows using FarmVibes Python client.

2 participants