Skip to content

Print exception stack trace when admin purge command fails - #4632

Merged
dimas-b merged 1 commit into
apache:mainfrom
vigneshio:fix-purge-command-stacktrace
Jun 10, 2026
Merged

dimas-b merged 1 commit into
apache:mainfrom
vigneshio:fix-purge-command-stacktrace

Conversation

@vigneshio

Copy link
Copy Markdown
Contributor

When the admin tool purge command fails with an unexpected exception, it now
prints the exception stack trace to stderr before the generic error message,
matching the existing behavior of the bootstrap command.

Why

Previously the catch (Exception e) block in PurgeCommand printed only a
generic line - "Purge encountered errors during operation." - and discarded the
exception entirely. A failed purge (e.g. database connection failure, realm not
found, permission denied) gave operators zero diagnostic information, making
production issues hard to triage. BootstrapCommand already prints the stack
trace via e.printStackTrace(spec.commandLine().getErr()); this change brings
purge in line with that convention.

Changes

  • PurgeCommand: print the caught exception's stack trace to stderr in the
    failure path.
  • Added PurgeCommandTest covering the failure path: a stub
    MetaStoreManagerFactory whose purgeRealms throws, asserting stderr contains
    the exception details and that the command returns EXIT_CODE_PURGE_ERROR.
  • CHANGELOG.md: added a Fixes entry.

Testing

  • ./gradlew :polaris-admin:test --tests "org.apache.polaris.admintool.PurgeCommandTest" - pass
  • ./gradlew :polaris-admin:spotlessCheck :polaris-admin:checkstyleMain :polaris-admin:checkstyleTest - pass
  • ./gradlew :polaris-admin:compileTestJava - pass

Checklist

  • 🛡️ Don't disclose security issues! (contact [email protected])
  • 🔗 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)

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

This fix LGTM 👍 Thanks, @vigneshio !

@github-project-automation github-project-automation Bot moved this from PRs In Progress to Ready to merge in Basic Kanban Board Jun 9, 2026
@dimas-b
dimas-b merged commit ef9fb74 into apache:main Jun 10, 2026
24 checks passed
@github-project-automation github-project-automation Bot moved this from Ready to merge to Done in Basic Kanban Board Jun 10, 2026
@dimas-b dimas-b mentioned this pull request Jun 10, 2026
2 of 6 tasks
snazy pushed a commit that referenced this pull request Jun 10, 2026
... apparently caused by merge overlap between #4632 and #4397
@vigneshio
vigneshio deleted the fix-purge-command-stacktrace branch June 22, 2026 14:07
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.

2 participants