Skip to content

fix: accept tags in raw automation preflight and saved drafts - #731

Merged
neubig merged 4 commits into
mainfrom
fix/oss-15302-preflight-tags
Nov 12, 2026
Merged

neubig merged 4 commits into
mainfrom
fix/oss-15302-preflight-tags

Conversation

@neubig

@neubig neubig commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

Why

Fixes #723 (OSS-15302). Raw automation create/update accepts tags, but preflight and saved-draft validation reject the field as extra_forbidden.

Summary

  • Add tags only to RawAutomationDraftBody, using the existing creation description and normalize_tags validator.
  • Keep unknown fields and preset tags forbidden; enforce existing slug/count/length/type rules.
  • Add real route/storage regressions and captured before/after live Agent Canvas evidence.

How to Test

uv run pytest tests/test_capabilities_router.py tests/test_draft_router.py tests/test_automation_tags.py tests/test_schemas.py

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 261719d versus implementation 3c7b869. The only automation production change is eight added lines in the raw draft schema; evidence commit does not alter it.

Live case Before After
Omitted tags valid valid
Populated / empty / normalized tags extra_forbidden valid
Invalid slug / count / length extra_forbidden addressed tags: value_error
Unknown field / preset tags rejected still rejected
Save/reload normalized draft HTTP 422 HTTP 201, ['example-tag'] persisted

Reproduction 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

Before: real Canvas run After: real Canvas run
Before After

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
Strongest signal: No primary concern selected.
Evidence: No primary concern to locate.
Coverage: ⚠️ reduced context — partial coverage; 14/14 hunks, 14/14 files (context budget: 13, missing patch: 2).

All estimates and evidence
Estimate Likelihood / value Direct evidence
SQL injection 3.0% No direct hunk selected
Command injection 5.0% No direct hunk selected
Weakened authentication 5.0% No direct hunk selected
Weakened authorization 7.0% No direct hunk selected
Contract regression 15.0% No direct hunk selected
Data loss 8.0% No direct hunk selected
Sensitive data disclosure 17.0% No direct hunk selected
Unexpected data transfer 4.0% No direct hunk selected
Credential misuse 7.0% No direct hunk selected
Untrusted instruction authority 3.0% No direct hunk selected
Package source redirection 4.0% No direct hunk selected
Unverified remote execution 4.0% No direct hunk selected
Privileged environment access 4.0% No direct hunk selected
Security assessment bypass 5.0% No direct hunk selected
Prohibited workload 2.0% No direct hunk selected
Primary concern None selected; confidence 80.0% No primary concern to locate

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>
@github-actions

Copy link
Copy Markdown
Contributor

📁 PR Artifacts Notice

This PR contains a .pr/ directory with temporary PR-specific documents. The directory will be automatically removed after this PR merges to main, through a cleanup PR.

@neubig
neubig requested a review from all-hands-bot November 11, 2026 14:01
@github-actions github-actions Bot added the type: fix A bug fix label Nov 11, 2026
@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Coverage

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.

@datadog-official

datadog-official Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Pipelines

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 83e3ed6 | Docs | Give us feedback!

Co-authored-by: openhands <openhands@all-hands.dev>
@neubig

neubig commented Nov 11, 2026

Copy link
Copy Markdown
Member Author

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.

@neubig
neubig requested review from all-hands-bot and removed request for all-hands-bot November 11, 2026 14:15
@neubig

neubig commented Nov 11, 2026

Copy link
Copy Markdown
Member Author

@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.

@neubig
neubig marked this pull request as ready for review November 11, 2026 15:03

@all-hands-bot all-hands-bot left a comment

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.

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: RawAutomationDraftBody now accepts tags with the same TAGS_DESCRIPTION and normalize_tags validator that CreateAutomationRequest uses. Bad slugs/count/length surface as tags: value_error, non-list values as list_type, and unknown fields stay extra_forbidden. Preset-endpoint drafts still reject tags, which matches preset creation schemas (CreatePromptAutomationRequest/CreatePluginAutomationRequest also 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 injected tags: [] in stored bodies that the regression test update covers.
  • No migration needed: drafts store draft_body as JSON and Automation.tags already 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 --frozen OK, ruff clean on changed files, tests/test_schemas.py 33 passed, and a direct probe of the changed schema confirmed default [], normalization, value_error, extra_forbidden, and the tags: [] injection in normalize_draft_body output.

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)

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.

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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>
@neubig
neubig requested a review from all-hands-bot November 11, 2026 15:44

@all-hands-bot all-hands-bot left a comment

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.

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: RawAutomationDraftBody now accepts tags with the same TAGS_DESCRIPTION and normalize_tags validator as CreateAutomationRequest. A direct probe of both models confirmed identical outcomes: value_error for bad slugs / >50 chars / >10 tags, list_type for non-list values, extra_forbidden preserved for unknown fields, and normalization (" Software Factory " → software-factory with dedupe).
  • The prior finding is fixed: _materialize_raw_draft now 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/CreatePluginAutomationRequest do not accept tags, their draft bodies still reject tags as extra_forbidden, and their materializers need no change.
  • Storage/compat: no migration needed — drafts store draft_body as JSON and Automation.tags already exists. Stored bodies now always include tags: [] (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, including unit-tests (the required full suite) and windows-tests.
  • Local workspace (Docker unavailable, so testcontainer-backed router suites could not run here): uv sync --frozen OK; ruff clean on changed files; pyright 0 errors on both changed production files; tests/test_schemas.py 33 passed; tests/test_draft_execution_regressions.py 6 passed (SQLite, includes the new tags-dispatch regression); tests/test_automation_tags.py SQLite 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

@neubig
neubig merged commit 949c001 into main Nov 12, 2026
14 checks passed
@openhands-release-bot openhands-release-bot Bot added the released: 1.33.0 Shipped in 1.33.0 label Nov 17, 2026
@openhands-release-bot

Copy link
Copy Markdown
Contributor

🚀 Released in 1.33.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released: 1.33.0 Shipped in 1.33.0 type: fix A bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Preflight validation rejects supported automation tags

3 participants