feat(auth,client): surface integration type and guide past root-page error#32
Merged
Conversation
…error
The Notion API returns a technically-accurate but hard-to-action
validation error when an internal integration tries to create a page at
the workspace root:
validation_error: Provide a parent.page_id or parent.database_id
parameter to create a page, or use a public integration with
insert_content capability. Internal integrations aren't owned by a
single user, so creating workspace-level private pages is not
supported.
Two small improvements so users don't have to parse that paragraph:
1. `notion auth status` and `notion auth doctor` now derive the
integration type from bot.owner.type ("workspace" → internal,
"user" → public) and print it. For internal integrations a follow-up
line reminds the user they must share a parent page first.
2. client.errorHint matches the internal-integration validation_error
signature and prints a concrete workaround with the exact next command:
→ Internal integrations can't create pages at the workspace root.
Workaround: create (or pick) a parent page in the Notion UI,
share it with this integration, then pass its ID as the parent:
notion page create <shared-page-id> --title "..."
To list pages shared with your integration: notion page list
Detection code is small (detectIntegrationType in cmd/auth.go) and
defensive: unknown or missing owner shape returns "" so pre-existing
response fixtures that don't include bot.owner still render fine.
Closes #25
da46ac4 to
bb6295f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Two small nudges so first-time users don't have to parse a Notion paragraph to understand why root-page creation fails with an internal integration:
notion auth statusandnotion auth doctornow print the integration type (internal/public) derived frombot.owner.typeon/v1/users/me.validation_errormatches the internal-integration root-page signature,client.errorHintappends a concrete workaround with the exact command to run next.Why
Tracked in #25. The underlying API error is technically accurate but not actionable — this PR turns it into something copy-pasteable.
Before / After
notion auth status(internal integration)Error wrap (internal integration hitting workspace root)
Changes
cmd/auth.go:detectIntegrationType(botInfo)readsbot.owner.type; unknown/missing shapes return""so the UI gracefully omits the lines. Used in bothauth statusandauth doctor.internal/client/client.go:errorHintmatches theInternal integrations aren't owned/insert_contentsignatures and returns a multi-line workaround.Test plan
TestDetectIntegrationType: workspace-owned → internal, user-owned → public, missing/unknown shapes → empty.TestErrorHintcases for both signature variants.setupAuthTestfixture to includebot.ownersoauth statustests still pass and now exercise the new branches.auth statusrender and the liveapi POST /v1/pageserror hint.Closes #25