Skip to content

Fix bootstrap silently creating realms with an unreachable root principal - #5526

Merged
dimas-b merged 1 commit into
apache:mainfrom
ayushtkn:bootstrapUnreachableRealm
Sep 18, 2026
Merged

dimas-b merged 1 commit into
apache:mainfrom
ayushtkn:bootstrapUnreachableRealm

Conversation

@ayushtkn

Copy link
Copy Markdown
Member

bootstrap required credentials only when none at all were supplied:

if (credentials == null || credentials.isEmpty()) {
  if (!printCredentials) { ... return EXIT_CODE_BOOTSTRAP_ERROR; }
}

A non-empty but incomplete list passes that check, so this succeeds and reports both realms bootstrapped:

polaris-admin bootstrap -r realm1 -r realm2 -c realm1,client1,s3cr3t

realm2 gets a random secret, because PrincipalSecretsGenerator.bootstrap falls back to RANDOM_SECRETS for any realm absent from the credentials map, and without --print-credentials that secret is never shown. Nothing validates the realm named in a --credential either, so a misspelled one (-r realm1 -c realm2,...) produces the same result.

The realm is then unusable: root is its only principal, no credential can be minted without it, and re-running bootstrap skips an already bootstrapped realm. Recovery requires purge and a second bootstrap.

The guard now checks that every requested realm is covered, and names the ones that are not. --print-credentials short-circuits as before. A partially covered invocation without it now exits non-zero instead of bootstrapping the uncovered realms unusably.

Checklist

  • 🛡️ Don't disclose security issues! (contact security@apache.org)
  • 🔗 Clearly explained why the changes are needed, or linked related issues: Fixes #
  • 🧪 Added/updated tests with good coverage, or manually tested (and explained how)
  • 💡 Added comments for complex logic
  • 🧾 Updated CHANGELOG.md (if needed)
  • 📚 Updated documentation in site/content/in-dev/unreleased (if needed)

Copilot AI lite review requested due to automatic review settings September 16, 2026 02:36
@github-project-automation github-project-automation Bot moved this to PRs In Progress in Basic Kanban Board Sep 16, 2026

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.

🟡 Changes recommended

Correct the invalid --credentials diagnostic and address the new multi-realm CLI documentation requirement.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

This PR prevents bootstrapping realms without reachable root credentials by validating credential coverage for every requested realm.

Changes:

  • Rejects incomplete or misspelled realm credentials.
  • Adds tests for incomplete credential input.
File summaries
File Summary
runtime/admin/src/test/java/org/apache/polaris/admintool/BootstrapCommandTestBase.java Adds validation-failure test coverage.
runtime/admin/src/main/java/org/apache/polaris/admintool/BootstrapCommand.java Validates credential coverage and reports uncovered realms. The diagnostic should use --credential, and the new multi-realm requirement should be documented.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread runtime/admin/src/main/java/org/apache/polaris/admintool/BootstrapCommand.java Outdated
@ayushtkn
ayushtkn force-pushed the bootstrapUnreachableRealm branch 2 times, most recently from 6fa69fb to 3bd8670 Compare September 16, 2026 07:15
dimas-b
dimas-b previously approved these changes Sep 16, 2026

@dimas-b dimas-b 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.

Nice catch 👍 Thanks a lot, @ayushtkn !

@github-project-automation github-project-automation Bot moved this from PRs In Progress to Ready to merge in Basic Kanban Board Sep 16, 2026
@dimas-b dimas-b added this to the 1.8.0 milestone Sep 16, 2026

@vigneshio vigneshio 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.

LGTM.. Thanks @ayushtkn

@dimas-b dimas-b removed this from the 1.8.0 milestone Sep 17, 2026
nandorKollar
nandorKollar previously approved these changes Sep 17, 2026
…ipal

bootstrap required --credential or --print-credentials only when no
credentials at all were supplied. A non-empty but incomplete list passed
that check, so any realm not named in it was bootstrapped with a
generated secret that is never printed. PrincipalSecretsGenerator falls
back to RANDOM_SECRETS for a realm absent from the credentials map, and
the command still reported the realm successfully bootstrapped.

Nothing validates that the realm named in a --credential triplet is one
of the requested realms either, so a misspelled realm name produced the
same result.

Such a realm cannot be used or recovered: its root principal is the only
principal, no other credential can be minted without it, and re-running
bootstrap is a no-op for an existing realm. The guard now covers every
requested realm and names the ones that are missing credentials.
@ayushtkn
ayushtkn dismissed stale reviews from nandorKollar and dimas-b via 63601bf September 18, 2026 14:38
@ayushtkn
ayushtkn force-pushed the bootstrapUnreachableRealm branch from 3bd8670 to 63601bf Compare September 18, 2026 14:38
@ayushtkn

Copy link
Copy Markdown
Member Author

Had to rebase, to resolve conflicts. Only CHANGELOG had conflicts, rest stays as is

@dimas-b dimas-b 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.

Merging based on previous approvals.

@dimas-b
dimas-b merged commit c90944e into apache:main Sep 18, 2026
24 checks passed
@github-project-automation github-project-automation Bot moved this from Ready to merge to Done in Basic Kanban Board Sep 18, 2026
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.

6 participants