Skip to content

fix(afspec): coerce Subtask.details string to list before validation (fixes #658)#659

Open
mickume wants to merge 1 commit into
mainfrom
fix/issue-658-tasks-details-string-coercion
Open

fix(afspec): coerce Subtask.details string to list before validation (fixes #658)#659
mickume wants to merge 1 commit into
mainfrom
fix/issue-658-tasks-details-string-coercion

Conversation

@mickume

@mickume mickume commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Summary

Added a Pydantic field_validator with mode="before" on Subtask.details that coerces a bare string into a single-element list. This fixes spec generate consistently failing on the tasks artifact because the LLM produces details as a string instead of list[str], causing a PydanticValidationError before the repair flow can run.

Closes #658

Changes

File Change
packages/afspec/afspec/models.py Added field_validator("details", mode="before") on Subtask to coerce str → [str]
packages/afspec/tests/test_models.py Added 6 tests covering string coercion, list passthrough, empty list, default, model_validate, and nested TaskGroup deserialization

Tests

  • TestSubtaskDetailsCoercion::test_string_coerced_to_list — bare string becomes single-element list
  • TestSubtaskDetailsCoercion::test_list_unchanged — existing list input passes through
  • TestSubtaskDetailsCoercion::test_empty_list_unchanged — empty list preserved
  • TestSubtaskDetailsCoercion::test_default_is_empty_list — default factory unaffected
  • TestSubtaskDetailsCoercion::test_model_validate_with_string_detailsmodel_validate coerces string
  • TestSubtaskDetailsCoercion::test_model_validate_nested_in_task_group — works through nested TaskGroup

Verification

  • All existing tests pass: ✅ (5731 passing, same 14 pre-existing failures)
  • New tests pass: ✅ (6/6)
  • Linter / formatter: ✅
  • No regressions: ✅

Auto-generated by af-fix.

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.

spec generate: tasks artifact always produces details as string instead of list[str]

1 participant