Skip to content

fix: stop search failing across more than five projects on Spanner - #3031

Merged
fforootd merged 1 commit into
mainfrom
claude/spanner-check-projects
Nov 12, 2026
Merged

fforootd merged 1 commit into
mainfrom
claude/spanner-check-projects

Conversation

@fforootd

@fforootd fforootd commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

Summary

  • On Spanner, POST /search without project_id answered 500 internal ("authz permission check failed") for a person who can act on more than five projects.
  • The search decides which of the newest ten projects the person may read in one statement (WriteCheckAuthzProjects, from feat(api): search every project a session can act on, each type from an index #2972): a UNION ALL arm per project, each with four joins. Ten projects are 40 joins, and Spanner refuses a query with more than 20.
  • Spanner's CheckAuthzProjects now asks in statements of four projects (16 joins) and puts each answer back in the order asked. Postgres and SQLite keep one statement.
  • It also wraps its query error, as the statements beside it do.

Validation

  • go test ./internal/storage/dialect/... (from apps/api): passes. The new TestCheckAuthzProjectsStatementStaysWithinSpannersJoinLimit counts the joins of one statement for each principal type, so a check that gains a join fails there before it fails on Spanner.
  • go test -tags sqlite_integration -run TestSearchAcrossProjectsStatements ./internal/storage/stmttest/: passes. The portable suite now checks ten projects at once and compares each answer with the one-project check, so it covers the chunking on Spanner.
  • go test -tags sqlite_integration -run TestSearchAcrossProjects ./internal/api/integration_test/: passes.
  • go vet -tags spanner_integration and the repo's analyzers on the two packages: clean. gofmt -l: clean.
  • Spanner Omni, before: on build: replace moon with Turborepo and run CI as one turbo graph #2881, which runs the lane on every push (run 43266360323), the two subtests of TestSearchAcrossProjects that read ten projects answered 500; the ones with two or three projects passed. The log does not show Spanner's own error, so the join limit was measured (40 joins in the statement, 20 allowed), not quoted.
  • Spanner Omni, with this change: spanner.yml dispatched on this branch. Every subtest of TestSearchAcrossProjects passes, the two ten-project ones included, and so does TestSearchAcrossProjectsStatements with its ten-project check. internal/api/integration_test, dialect/spanner and stmttest are ok.
  • Not run: the Postgres lane locally (CI's full-pr runs it).

Release notes / changeset

  • .changeset/search-across-projects-spanner.md: @zitadel/server patch.

Notes

  • Main's weekly Spanner run fails on this search until this lands, and on the migration round trip until test(api): let the Spanner round-trip walks take migrations as they free up #2997 does.
  • Ten projects are now three round trips on Spanner instead of one. Four per statement rather than five leaves room for one more join in the check.
  • The other two cross-project statements (SearchEntriesInProjects, SearchUserIndex) write arms without joins, so they stay within Spanner's limits at ten projects.

🤖 Generated with Claude Code

A search without project_id decides which of the newest ten projects the
person may read in one statement, a UNION ALL arm per project with four
joins each: 40 joins for ten projects. Spanner refuses a query with more
than 20, so the search answered 500 "authz permission check failed"
(TestSearchAcrossProjects on the Spanner Omni lane).

Spanner's CheckAuthzProjects now asks in statements of four projects and
wraps its error as its neighbours do. Postgres and SQLite keep one statement.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 12, 2026 17:58
@vercel

vercel Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
cloud Ready Ready Preview Nov 12, 2026 6:01pm UTC

Request Review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
🔒 Security Review ✅ Completed 2026-11-12T18:08:20.578068Z 7094105 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

Copy link
Copy Markdown
Contributor

🦋 Changeset detected

Latest commit: 7094105

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 25 packages
Name Type
@zitadel/server Patch
@zitadel/cli Patch
@zitadel/testing Patch
@zitadel/server-linux-x64 Patch
@zitadel/server-linux-arm64 Patch
@zitadel/server-darwin-x64 Patch
@zitadel/server-darwin-arm64 Patch
@zitadel/server-win32-x64 Patch
@zitadel/api Patch
@zitadel/config Patch
@zitadel/components Patch
@zitadel/sdk-core Patch
@zitadel/sdk-next Patch
@zitadel/sdk-nuxt Patch
@zitadel/sdk-react Patch
@zitadel/sdk-vue Patch
@zitadel/sdk-angular Patch
@zitadel/sdk-solid Patch
@zitadel/sdk-svelte Patch
@zitadel/sdk-qwik Patch
@zitadel/sdk-sveltekit Patch
@zitadel/sdk-solid-start Patch
@zitadel/sdk-qwik-router Patch
@zitadel/sdk-tanstack-start Patch
@zitadel/cloud Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copilot AI 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.

Note

Copilot was unable to complete this review at the selected tier due to model policy or plan restrictions.

🔵 Needs a closer look

The change depends on validating Spanner join-limit behavior in an integration lane/runtime that isn’t available in this review environment, so it can’t be confidently confirmed here.

No open issues 🎉

What changed in this PR

Fixes a Spanner-specific POST /search failure when no project_id is provided and the caller can act on more than five projects by chunking the project authorization check to stay under Spanner’s join limit while preserving per-project results and input order.

Changes:

  • Chunk Spanner CheckAuthzProjects into 4-project statements and wrap query errors consistently.
  • Expand portable statement tests to cover 10-project checks and validate per-project result ordering.
  • Add a Spanner-specific unit test to ensure generated SQL stays within Spanner’s join limit.
  • Add a patch changeset for @zitadel/server documenting the fix.
File Description
apps/​api/​internal/​storage/​stmttest/​search_batch_test.go Expands statement-level coverage to validate 10-project authorization checks and stable per-project result ordering across dialects.
apps/​api/​internal/​storage/​dialect/​spanner/​authz_resolver.go Chunks CheckAuthzProjects execution on Spanner into 4-project batches to avoid join-limit failures and wraps query errors consistently.
apps/​api/​internal/​storage/​dialect/​spanner/​authz_resolver_test.go Adds a regression test that counts joins in the generated CheckAuthzProjects SQL to ensure it stays within Spanner’s join limit.
.changeset/​search-across-projects-spanner.md Adds a @zitadel/server patch changeset describing the Spanner cross-project search fix.

Review effort: Balanced

@fforootd
fforootd added this pull request to the merge queue Nov 12, 2026
Merged via the queue into main with commit 83b3cfb Nov 12, 2026
28 of 29 checks passed
@fforootd
fforootd deleted the claude/spanner-check-projects branch November 12, 2026 20:08
@github-project-automation github-project-automation Bot moved this from Inbox to Done in Engineering Kanban Nov 12, 2026
fforootd added a commit that referenced this pull request Nov 12, 2026
Picks up #2997 and #3031, which this branch's Spanner Omni lane needs: the
round-trip walks (already here as cherry-picks, now main's) and the
ten-project search check within Spanner's join limit.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

This branch was successfully deployed

1 active deployment
Preview — 7094105c Deployed Nov 12, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants