Skip to content

fix(packs): accept both message_id and id in gmail message-targeting normalizers#47

Merged
fafaisland merged 4 commits into
mainfrom
claude/ecstatic-leavitt-ae911e
May 10, 2026
Merged

fix(packs): accept both message_id and id in gmail message-targeting normalizers#47
fafaisland merged 4 commits into
mainfrom
claude/ecstatic-leavitt-ae911e

Conversation

@fafaisland

@fafaisland fafaisland commented May 10, 2026

Copy link
Copy Markdown
Collaborator

Fixes #41.

Summary

  • Adds a from_any: Vec<String> fallback list to EntityDef. The extractor tries from first, then each entry in from_any in order, treating null as absent so a fallback can fill in.
  • Updates the seven gmail message-id normalizers (read, delete, archive, flag, mark_read, mark_spam, move) to declare from_any: ["id"].
  • Regenerates packs/permit0/email/pack.lock.yaml and adds two regression tests for the canonical and Google-style spellings.

Why

Issue #41: hooks were 500'ing with missing required field 'message_id' in tool call 'gmail_delete' (and the parallel error for read/move/archive/etc.) when the upstream MCP wrapper carried the message id under id rather than message_id.

Commit 753f283 hard-pinned from: "message_id" to match the canonical permit0-gmail MCP wrapper. That fixed the canonical wrapper but broke:

  • Google's official Gmail MCP (uses id)
  • Community Gmail MCP servers that follow Google's parameter naming
  • The conditional aliases in aliases.yaml that rewrite label_message/label_thread (with labelIds: ["TRASH"]) to gmail_delete — the alias rewrites the tool name only, leaving the original id parameter in place

from_any lets one normalizer accept multiple parameter spellings without forking per upstream.

Test plan

  • cargo test --workspace — green (added two regression tests in crates/permit0-dsl/tests/pack_integration.rs)
  • cargo clippy --workspace --all-targets -- -D warnings — green
  • End-to-end against a fresh permit0 serve --ui daemon:
    • gmail_delete with message_id → ALLOW
    • gmail_delete with id (was 500) → ALLOW
    • gmail_move with message_id + destination → ALLOW
    • label_message with id + labelIds: ["TRASH"] (alias-routes to gmail_delete) → ALLOW
    • gmail_delete with empty params → still errors as expected
  • Calibration cargo run -- calibrate test has 3 pre-existing failures on this branch (email send escalation from 753f283), unrelated to this change — confirmed by stash-and-test against main.

…normalizers

Commit 753f283 hard-pinned `from: "message_id"` to match the canonical
`permit0-gmail` MCP wrapper, but Google's official Gmail MCP, community
wrappers, and the conditional aliases that rewrite `label_message`/
`label_thread` to `gmail_delete` all carry the message id under `id`.
Those calls 500'd with "missing required field 'message_id' in tool
call 'gmail_delete'" because the normalizer only checked one path.

Adds a `from_any: Vec<String>` fallback list to `EntityDef`. The
extractor tries `from` first, then each entry in `from_any` in order,
treating null as absent so a fallback can fill in. Updates the seven
gmail message-id normalizers (read, delete, archive, flag, mark_read,
mark_spam, move) to declare `from_any: ["id"]`. Regenerates the email
pack lockfile and adds two regression tests for the canonical and
Google-style spellings.
@fafaisland fafaisland requested a review from AnissL93 as a code owner May 10, 2026 20:38
Su Fu added 3 commits May 10, 2026 13:42
Pre-existing whitespace drift from commit 753f283 — affects four files
in permit0-cli and permit0-dsl that this PR didn't otherwise touch.
CI's Format check blocks merge until rustfmt is satisfied; bundling the
trivial reformat here so #41's fix can land.
Pre-existing block on main. webpki-roots (transitively via ureq) ships
Mozilla's root cert bundle under CDLA-Permissive-2.0 — a permissive
data-sharing license. Adding it to the allow list so cargo-deny CI
passes for this PR; tracked alongside the permissive code licenses
already on the list.
@fafaisland fafaisland merged commit 01d2428 into main May 10, 2026
8 checks passed
@fafaisland fafaisland deleted the claude/ecstatic-leavitt-ae911e branch May 10, 2026 21:08
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.

[bug] mcp gmail delete missing 'message_id'

1 participant