Skip to content

fix(api): skip unsupported block-children errors instead of aborting sync - #60

Merged
steipete merged 3 commits into
openclaw:mainfrom
oliver-mee:fix/api-ai-block-sync-abort
Jul 16, 2026
Merged

steipete merged 3 commits into
openclaw:mainfrom
oliver-mee:fix/api-ai-block-sync-abort

Conversation

@oliver-mee

Copy link
Copy Markdown
Contributor

Summary

GET /blocks/{id}/children returns a 400 validation_error when a page contains a block type the API cannot return to this integration (seen with Notion AI blocks: "Block type ai_block is not supported via the API for your bot type."). That error propagated unhandled and aborted the entire sync --source api run, the same failure shape as #37 and #39 but a different Notion block type triggering it.

This classifies that specific 400 as non-fatal: skip the unfetchable children batch, record a warning (surfaced the same way existing warnings already are, via Summary.Warnings / writeAPIWarnings on stderr), and keep syncing the rest of the workspace. It also gates the page_blocks "complete" marker and RetireSourcePageBlocksNotSyncedAt on zero warnings: without that gate, a page that synced cleanly before would have its already-synced blocks retired the next run it also happens to contain one unfetchable block. An independent review pass (Claude Opus 4.8) caught that specific regression before this PR was opened, see Model used below.

Linked issue

Fixes #59

Type of change

  • Bug fix (non-breaking)
  • New feature (non-breaking)
  • Breaking change
  • Refactor or cleanup (no behaviour change)
  • Documentation
  • CI, tooling, or config

How to test

  1. GOWORK=off go test ./..., go vet ./..., gofmt -l . all clean, including the 3 new tests (TestWalkBlocksSkipsUnsupportedBlockChildren, TestIngestPageLeavesIncompleteWhenBlockChildrenUnsupported, TestWalkBlocksDoesNotRetirePreviousBlocksOnPartialWalk).
  2. go build ./cmd/notcrawl, then run notcrawl sync --source api against a workspace with an ai_block present. I ran this against my own production workspace (7,573 pages, one page with an ai_block) and confirmed the patched binary gets past the exact page the unpatched binary aborted on, printing warning: Skipped children of block ... on page ... to stderr instead of dying.

Checklist

  • One concern only, scope limited to the summary above
  • I ran it and verified end to end: full suite, vet, gofmt, plus a real sync against a 7,573-page production workspace, not just unit tests.
    • Windows: not tested. N/A, disclosed honestly: no Windows box available. The change is pure Go with no OS-specific paths.

Model used

Claude Sonnet 5 implemented this. A separate Claude Opus 4.8 pass independently reviewed the diff and caught a real bug: the first version only gated SetSyncState(..., "complete") on the warnings, missing that RetireSourcePageBlocksNotSyncedAt needed the same gate, or a previously-clean page would lose its valid blocks the next time it also hit one unfetchable block. That fix is included here.


🤖 Generated with Claude Code (Claude Sonnet 5)
🧑‍💻 Ideated, directed and reviewed by a human, @Omee11

…sync

GET /blocks/{id}/children returns a 400 validation_error when a page
contains a block type the integration cannot receive (seen with Notion
AI blocks: "Block type ai_block is not supported via the API for your
bot type."). This aborted the entire sync --source api run, regardless
of how many other pages were left to sync.

Classify this specific 400 as non-fatal: skip the unfetchable children
batch, record a warning, and continue. The page_blocks "complete" sync
marker and RetireSourcePageBlocksNotSyncedAt are both now gated on zero
warnings, so a page that synced cleanly before does not have its
previously-synced blocks retired the next time it also contains one
unfetchable block.

Adds isUnsupportedBlockChildrenError and threads a []string warnings
return through walkBlocksAt -> walkBlocks -> ingestPage -> Sync,
reusing the existing Summary.Warnings / writeAPIWarnings stderr path
already used for the forbidden-/users and restricted-resource cases.

Covered by three new tests:
- TestWalkBlocksSkipsUnsupportedBlockChildren
- TestIngestPageLeavesIncompleteWhenBlockChildrenUnsupported
- TestWalkBlocksDoesNotRetirePreviousBlocksOnPartialWalk

Fixes openclaw#59
@clawsweeper

clawsweeper Bot commented Jul 2, 2026 •

Copy link
Copy Markdown

Codex review: needs maintainer review before merge. Reviewed July 14, 2026, 2:15 PM ET / 18:15 UTC.

Summary
The PR converts narrowly identified unsupported block-children API responses into warnings, preserves previously synchronized blocks during partial traversal, and adds regression tests.

Reproducibility: no. fresh live reproduction was established on current main SHA d9540fd, but the exact pre-fix request, response, propagation path, and production failure are documented well enough to reproduce from source and a suitable Notion workspace.

Review metrics: 3 noteworthy metrics.

  • Patch surface: 2 files changed. The fix remains confined to Notion API ingestion and its tests.
  • Regression coverage: 3 targeted tests added. The tests cover error tolerance, incomplete-state marking, and preservation of previously synchronized blocks.
  • Runtime proof scale: 7,573-page live workspace. The contributor exercised the patched behavior on the real dataset that originally exposed the fatal response.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #59
Summary: This PR is the direct candidate fix for the linked ai_block synchronization-abort issue; earlier API-resilience reports are related patterns but distinct root causes.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🦞 diamond lobster
Proof: 🦞 diamond lobster
Patch quality: 🦞 diamond lobster
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Risk before merge

  • [P1] The branch was based on 7754b9d while current main is d9540fd, so targeted Go validation should be refreshed on the final merged head.
  • [P1] The GitHub check set shown here contains repository automation checks but not the claimed Go test and vet runs; the detailed production proof and regression tests reduce this uncertainty but do not replace final maintainer validation.

Maintainer options:

  1. Decide the mitigation before merge
    Land the narrow warning-based recovery while retaining prior blocks whenever traversal is incomplete, after refreshing the focused tests and full Go validation against current main.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • No automated repair is needed; a maintainer should refresh validation against current main and review or merge the existing focused PR.

Security
Cleared: The two-file Go patch changes API error handling and tests without adding dependencies, executable supply-chain inputs, permissions, credential handling, or broader secret exposure.

Review details

Best possible solution:

Land the narrow warning-based recovery while retaining prior blocks whenever traversal is incomplete, after refreshing the focused tests and full Go validation against current main.

Do we have a high-confidence way to reproduce the issue?

No fresh live reproduction was established on current main SHA d9540fd, but the exact pre-fix request, response, propagation path, and production failure are documented well enough to reproduce from source and a suitable Notion workspace.

Is this the best way to solve the issue?

Yes. Narrowly classifying the known unsupported response as a warning while withholding completion and retirement on partial traversal is safer than aborting the workspace sync or pretending the page was fully synchronized.

AGENTS.md: unclear because the file could not be read completely.

Codex review notes: model internal, reasoning high; reviewed against d9540fd763f9.

Label changes

Label changes:

  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.

Label justifications:

  • P2: A single unsupported Notion block can abort an API synchronization run, but the failure is bounded to the API source and has a focused fix with strong proof.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body provides after-fix production proof from a real 7,573-page Notion synchronization, including the formerly fatal condition and observed warning-based continuation.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides after-fix production proof from a real 7,573-page Notion synchronization, including the formerly fatal condition and observed warning-based continuation.
Evidence reviewed

What I checked:

  • Linked implementation candidate: The PR explicitly targets the still-open report at API sync aborts on ai_block children returning 400 validation_error #59, which documents the same 400 validation_error abort and identifies this PR as the open fix path. (839ba312a612)
  • Focused implementation: The patch threads warnings through block traversal and page ingestion, and only marks page-block synchronization complete or retires old blocks after a warning-free traversal. (internal/notionapi/api.go:245, 839ba312a612)
  • Regression coverage: The branch adds tests for skipping unsupported child requests, leaving partial page ingestion incomplete, and retaining blocks from an earlier complete synchronization. (internal/notionapi/api_test.go:443, 839ba312a612)
  • Real behavior proof: The PR body reports running the patched binary against a real 7,573-page workspace containing an ai_block; synchronization continued past the formerly fatal page and emitted the expected warning. (839ba312a612)
  • Re-review continuity: The current head matches the previously reviewed SHA, whose completed ClawSweeper review reported no findings and accepted the production proof; no new contributor commits or maintainer review notes were provided afterward. (839ba312a612)
  • Current-main comparison: No merged related PR or supplied current-main evidence shows that SHA d9540fd already contains this behavior, so the proposed fix remains necessary. (internal/notionapi/api.go:1, d9540fd763f9)

Likely related people:

  • Vincent Koc: The Notcrawl codebase and its Notion crawling behavior appear to originate from Vincent Koc's earlier project history, making him a likely domain-routing candidate for the API traversal design. (role: original feature owner; confidence: low; files: internal/notionapi/api.go, internal/notionapi/api_test.go)
  • steipete: The repository now lives under OpenClaw, making steipete a plausible reviewer for current project behavior and release integration, although local commit attribution could not be confirmed. (role: recent repository steward; confidence: low; commits: d9540fd763f9; files: internal/notionapi/api.go)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
Review history (1 earlier review cycle)
  • reviewed 2026-07-02T13:49:16.110Z sha 839ba31 :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P2 Normal priority bug or improvement with limited blast radius. labels Jul 2, 2026
@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Jul 14, 2026
@steipete

Copy link
Copy Markdown
Contributor

Maintainer refresh on exact head b9829ab0389d03282e73b0a35c07a27dfbf15221:

  • merged current main into the contributor branch without rewriting contributor history
  • added Unreleased changelog credit
  • GOWORK=off go test ./...
  • GOWORK=off go vet ./...
  • test -z "$(gofmt -l .)"
  • built the real CLI and exercised isolated init, repeated status --json, help, and invalid-command handling
  • autoreview against origin/main: no accepted/actionable findings (0.91 confidence)

The exact ai-block live clause could not be rerun locally because the existing environment reports api_token_present=false; no new credential was created. The contributor's documented 7,573-page workspace proof remains the available live proof for that exact condition.

Hosted CI did not emit for this fork update; only autolabel passed and release-draft skipped. No merge performed.

@steipete
steipete merged commit 838580d into openclaw:main Jul 16, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix P2 Normal priority bug or improvement with limited blast radius. proof: sufficient Contributor real behavior proof is sufficient. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

API sync aborts on ai_block children returning 400 validation_error

3 participants