Skip to content

fix: collapse context-block validation error cascade#88

Merged
zhawtof merged 1 commit into
mainfrom
claude/gifted-merkle-b36431
Jun 2, 2026
Merged

fix: collapse context-block validation error cascade#88
zhawtof merged 1 commit into
mainfrom
claude/gifted-merkle-b36431

Conversation

@zhawtof
Copy link
Copy Markdown
Contributor

@zhawtof zhawtof commented Jun 1, 2026

Problem

Removing all items from a context block produced a wall of ~25 raw AJV errors in the editor popover (and the issues sheet) — must be equal to constant, must have required property 'hero_image', must match a schema in anyOf, etc. Only one of them was real: the block needs ≥1 element.

Root cause

Two compounding issues:

  1. Stale validator. @tightknitai/slack-block-kit-validator was pinned at 0.1.0-alpha.0 — the first alpha, which predates the formatAjvErrors focus-validator collapse. When a block fails its branch in the undiscriminated block-type oneOf, that version reports failures from every branch.
  2. Parser coupled to the old format. 0.1.7 collapses the cascade and changes the error-string format (/N/...blocks[N]..., with caveat messages using a space rather than a colon). error-grouping.ts parsed the old /N/... shape, so a naive bump alone would route every error into the "General" bucket — blanking the per-block popover and the row's error indicator.

Changes

  • Bump @tightknitai/slack-block-kit-validator ^0.1.0-alpha.0^0.1.7. Verified API-compatible (identical exports/signatures/result shape); schema diff is 5 additive lines (one optional level field), nothing that newly flags valid blocks.
  • Rewrite error-grouping.ts for the blocks[N]... path format — strips the blocks[N] prefix while keeping sub-paths as context, handles space-separated caveat-helper messages, (root) errors, and out-of-range indices.
  • Empty-state UX in context-editor.tsx: when the block has no items, show a calm guiding hint ("add an item, or delete the block") instead of relying solely on a red error. Empty is allowed — Send is already gated on errorCount > 0 — rather than fighting the user mid-edit.
  • Tests (test/error-grouping.test.ts, 13 cases) including an integration test that runs the real validator on an empty context block, pinning the validator/parser format coupling so future drift fails loudly instead of silently emptying the popover.

Result

The same action now yields a single, correctly-attributed error — elements: fewer than 1 items — plus the empty-state hint. Toolbar shows "1 issue" instead of a wall.

Verification

  • pnpm test230/230 pass (13 new)
  • pnpm typecheck — clean
  • pnpm lint — clean
  • Reproduced live in the demo app (remove last context item): 1 collapsed error + empty-state hint, no console errors.

🤖 Generated with Claude Code

Removing all items from a context block surfaced ~25 raw AJV union-branch
errors in the editor popover (and issues sheet) instead of the one real
constraint. The cause was a stale validator (0.1.0-alpha.0, pre-collapse)
paired with an error-grouping parser written for that version's path format.

- Bump @tightknitai/slack-block-kit-validator 0.1.0-alpha.0 -> 0.1.7, which
  collapses the AJV oneOf cascade via per-type focus validators.
- Rewrite error-grouping for 0.1.7's `blocks[N]...` path format so errors
  stay attributed to their block; the new format would otherwise fall into
  the General bucket, blanking the per-block popover and the row indicator.
- Add a calm empty-state hint to the context editor that guides the user to
  add an item or delete the block, rather than only showing a red error.
- Add error-grouping tests, including one that runs the real validator to
  pin the validator/parser format coupling so future drift fails loudly.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@cloudflare-workers-and-pages
Copy link
Copy Markdown
Contributor

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
block-kitchen 7d46d1a Commit Preview URL

Branch Preview URL
Jun 01 2026, 06:01 AM

@zhawtof zhawtof merged commit 9f696c4 into main Jun 2, 2026
13 checks passed
@zhawtof zhawtof deleted the claude/gifted-merkle-b36431 branch June 2, 2026 04:03
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.

1 participant