Repository navigation
fix: accept tags in raw automation preflight and saved drafts - #731
Conversation
Reuse creation tag normalization during preflight and saved draft validation without widening preset schemas. Co-authored-by: openhands <openhands@all-hands.dev>
Co-authored-by: openhands <openhands@all-hands.dev>
|
📁 PR Artifacts Notice This PR contains a |
|
Warning Your comment is too long (maximum is 65536 characters), so the coverage report was not added. See the job log for how to reduce it. |
Co-authored-by: openhands <openhands@all-hands.dev>
|
Full-suite CI found one existing saved-draft equality assertion that did not expect the newly normalized empty tags list (2,881 other tests passed). Updated that expectation in 6a82eb5; all five SQLite draft-execution regressions now pass locally. The production fix and captured live after-run behavior are unchanged. Please review the latest head. This comment was generated by an AI agent (OpenHands) on behalf of Graham Neubig. |
|
@all-hands-bot Please review the latest head 6a82eb5. All 9 active CI checks are green, including 2,882 passing tests. Before/after live Canvas screenshots and real API request/response evidence are linked in the description. The draft is intentionally retained during the review/CI iteration loop; this is an explicit request for independent review and approval if there are no material findings. This comment was generated by an AI agent (OpenHands) on behalf of Graham Neubig. |
all-hands-bot
left a comment
There was a problem hiding this comment.
This review was posted by an AI agent (OpenHands).
Scope — in repository. Draft bodies and preflight validation for /v1 and /v1/drafts are Automation Service contracts owned here, and linked issue #723 targets this service's validate endpoint. No cross-repository dependency is involved.
Verified
- Validation parity with creation:
RawAutomationDraftBodynow acceptstagswith the sameTAGS_DESCRIPTIONandnormalize_tagsvalidator thatCreateAutomationRequestuses. Bad slugs/count/length surface astags: value_error, non-list values aslist_type, and unknown fields stayextra_forbidden. Preset-endpoint drafts still rejecttags, which matches preset creation schemas (CreatePromptAutomationRequest/CreatePluginAutomationRequestalso forbid it) — consistent, not an omission. - Both consumers of
normalize_draft_body—POST /v1/validate(capabilities_router) and draft create/update (draft_router) — now accept and persist normalized tags; the new regressions exercise real route + storage round-trips, including the injectedtags: []in stored bodies that the regression test update covers. - No migration needed: drafts store
draft_bodyas JSON andAutomation.tagsalready exists. Security surface unchanged: tags are normalized to bounded lowercase slugs and no auth/ownership path changes. - All three acceptance criteria from #723 are met.
Checks and tests
- CI on head
6a82eb5: all 9 checks green, including the full unit-test job (2,882 tests). - Local workspace (Docker unavailable, so testcontainer-backed router suites could not run here):
uv sync --frozenOK,ruffclean on changed files,tests/test_schemas.py33 passed, and a direct probe of the changed schema confirmed default[], normalization,value_error,extra_forbidden, and thetags: []injection innormalize_draft_bodyoutput.
Finding (one, non-blocking for the reported bug)
The draft → automation path drops draft tags; see inline comment. The issue's acceptance criteria are met, but accepting tags into draft bodies without carrying them through _materialize_raw_draft silently discards user input on the primary dispatch path, contradicting the create-parity this PR establishes. The fix is small: add "tags": body.tags, to the values dict in _materialize_raw_draft (the prompt/plugin materializers need nothing — their creation schemas don't accept tags).
🔄 CHANGES REQUESTED
| class RawAutomationDraftBody(_BaseDraftBody): | ||
| """Partial body for the raw `/v1` automation creation endpoint.""" | ||
|
|
||
| tags: list[str] = Field(default_factory=list, description=TAGS_DESCRIPTION) |
There was a problem hiding this comment.
This field is now accepted, validated, and persisted in raw draft bodies — but nothing consumes it. _materialize_raw_draft (draft_router.py:432) builds the materialized automation's values without tags, so a draft saved with tags: ["example-tag"] (proven persisted by test_raw_draft_tags_persist) dispatches into an automation whose tags stay at the model default [], on first creation and on every overwrite in _materialize_draft.
Before this PR a draft body could never contain tags, so nothing was dropped; accepting them without wiring them through dispatch introduces a silent gap on the primary draft → automation path, and the draft's validation now passes with tags the materialized automation will never carry. Suggested fix: include "tags": body.tags, in _materialize_raw_draft's returned dict (prompt/plugin materializers are unaffected — their creation schemas reject tags).
Happy to see this as an immediate follow-up if you'd rather keep this PR scoped to the validation fix, but as-is the parity claim in the description doesn't hold for dispatch.
There was a problem hiding this comment.
Fixed in 83e3ed6: raw materialization now includes body.tags. Added a real HTTP/SQLite regression that fails before the fix (materialized tags are []) and passes after: initial dispatch preserves normalized/deduplicated tags, redispatch updates tags on the same automation, and an empty list clears them. All six draft-execution regression tests pass; Ruff and diff checks pass. Please re-review the latest head.
This reply was generated by an AI agent (OpenHands) on behalf of Graham Neubig.
Co-authored-by: openhands <openhands@all-hands.dev>
all-hands-bot
left a comment
There was a problem hiding this comment.
This review was posted by an AI agent (OpenHands).
Scope — in repository. Draft-body and preflight validation for /v1 and /v1/drafts are Automation Service contracts owned here, and linked issue #723 targets this service. Verified the prior review's finding is addressed at this head.
Verified
- Creation parity:
RawAutomationDraftBodynow acceptstagswith the sameTAGS_DESCRIPTIONandnormalize_tagsvalidator asCreateAutomationRequest. A direct probe of both models confirmed identical outcomes:value_errorfor bad slugs / >50 chars / >10 tags,list_typefor non-list values,extra_forbiddenpreserved for unknown fields, and normalization (" Software Factory "→software-factorywith dedupe). - The prior finding is fixed:
_materialize_raw_draftnow passes"tags": body.tags, so draft dispatch and re-dispatch carry tags into the materialized automation. The new regression (test_raw_draft_tags_survive_dispatch_and_updates) covers create → dispatch → PATCH (update and clear tags) → re-dispatch and asserts the same automation is reused with updated tags — it passes locally on the SQLite engine. - Preset endpoints stay consistent:
CreatePromptAutomationRequest/CreatePluginAutomationRequestdo not accept tags, their draft bodies still rejecttagsasextra_forbidden, and their materializers need no change. - Storage/compat: no migration needed — drafts store
draft_bodyas JSON andAutomation.tagsalready exists. Stored bodies now always includetags: [](default_factory+exclude_none), which the updated draft-execution assertion reflects; pre-existing drafts without the key re-validate through the same model with the default. Git-sync serializer already emits tags when non-empty. - Security surface unchanged: tags are bounded lowercase slugs (≤10 × 50 chars); no auth, ownership, or secret path changes.
Checks and tests
- CI on head
83e3ed6: all checks green, includingunit-tests(the required full suite) andwindows-tests. - Local workspace (Docker unavailable, so testcontainer-backed router suites could not run here):
uv sync --frozenOK;ruffclean on changed files; pyright 0 errors on both changed production files;tests/test_schemas.py33 passed;tests/test_draft_execution_regressions.py6 passed (SQLite, includes the new tags-dispatch regression);tests/test_automation_tags.pySQLite param 15 passed; schema probes of validation parity as above.
No material findings. The production change is eight lines in the raw draft schema plus one tag-propagation line in the raw materializer; .pr/ evidence is temporary and handled by the existing cleanup workflow.
✅ APPROVED
|
🚀 Released in 1.33.0. |
Why
Fixes #723 (OSS-15302). Raw automation create/update accepts tags, but preflight and saved-draft validation reject the field as
extra_forbidden.Summary
tagsonly toRawAutomationDraftBody, using the existing creation description andnormalize_tagsvalidator.How to Test
167 passed. New regressions failed before the source fix (22 failed / 3 passed). Tests use PostgreSQL testcontainers; existing automation-tag tests also cover SQLite. Ruff, pycodestyle, targeted Pyright and diff checks pass.
Live QA used isolated local Canvas stacks, real HTTP and LLM/terminal execution, separate SQLite databases, exact base
261719dversus implementation3c7b869. The only automation production change is eight added lines in the raw draft schema; evidence commit does not alter it.extra_forbiddenextra_forbiddentags: value_error['example-tag']persistedReproduction commands, API responses and tool events.
This is Linux local-mode QA, not a reproduction in the customer's Enterprise deployment. No scheduled automation was created or dispatched; temporary saved drafts were deleted.
Before / after screenshots
Notes
No new dependency, database migration, or changes to preset tags.
.pr/contains temporary review evidence only.This PR was created by an AI agent (OpenHands) on behalf of Graham Neubig.
Jev-Fast-Audit
⚡ Jev fast audit · estimates · 0.34s · commit 83e3ed6⚠️ reduced context — partial coverage; 14/14 hunks, 14/14 files (context budget: 13, missing patch: 2).
Strongest signal: No primary concern selected.
Evidence: No primary concern to locate.
Coverage:
All estimates and evidence