Skip to content

fix: Setup NPE when optional parameters are missing (#956) - #982

Open
ismisepaul wants to merge 2 commits into
devfrom
dev#956-setup-npe
Open

ismisepaul wants to merge 2 commits into
devfrom
dev#956-setup-npe

Conversation

@ismisepaul

Copy link
Copy Markdown
Member

Fixes #956.

What

Setup.doPost called equalsIgnoreCase on the raw enableMongoChallenge and unsafeLevels parameters. A client that left either one out got HTTP 500 after setup had already written the database settings. The curl setup in docs/database-configuration.md and AGENTS.md leaves them out.

dboverride had the same problem. Leaving it out is valid: it means "neither override nor upgrade". So it's fixed here too, with its own test.

All three now compare with the constant first ("enable".equalsIgnoreCase(...)), so a missing parameter means "not enabled".

Tests

Two new SetupIT tests post setup on an instance that isn't installed yet, using the DB settings from .env:

  • without enableMongoChallenge / unsafeLevels
  • without dboverride

Both fail on dev with the NPE and pass with the fix. I also merged this branch with #959 (the setup advisory fix, which changes the same method) and ran SetupIT and SetupAuthTest on the result. It merges cleanly and both pass.

Every step of test.yml passed locally (lint, build, PGP check, compose build, Tomcat config check, unit tests, integration tests).

🤖 Generated with Claude Code

Setup.doPost called equalsIgnoreCase on the raw dboverride,
enableMongoChallenge and unsafeLevels parameters. A client that left one
out (as the curl setup in the docs does) got HTTP 500 after the database
settings had already been written. Compare with the constant first, so a
missing parameter means "not enabled" / "neither override nor upgrade".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ismisepaul ismisepaul added this to the 4.0.0 milestone Oct 24, 2026
Copilot AI balanced review requested due to automatic review settings October 24, 2026 23:33
@ismisepaul ismisepaul moved this from Backlog to Next Release Backlog in Security Shepherd Oct 24, 2026
Comment thread src/it/java/servlets/SetupIT.java Fixed

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

The new test helper must create its configuration directory so regression tests can run independently on a clean build.

1 open issue
What changed in this PR

Fixes setup failures when optional parameters are omitted, addressing #956 without changing behavior for supplied values.

Changes:

  • Uses null-safe comparisons for dboverride, enableMongoChallenge, and unsafeLevels.
  • Adds integration tests for setup requests that omit these parameters.
File Description
src/​main/​java/​servlets/​Setup.java Treats missing optional parameters as disabled or no override.
src/​it/​java/​servlets/​SetupIT.java Adds a shared request helper and two regression tests.

Review effort: Balanced

Comment thread src/it/java/servlets/SetupIT.java
Review follow-up. Pass the optional setup parameters as a map instead of
key/value varargs, and create the directory the setup auth file goes in,
so the new tests also pass when SetupIT runs alone on a clean build.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings October 25, 2026 00:14

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.

🟢 Approval recommended

The narrow null-safety fix preserves existing behavior, includes regression coverage, and has no unresolved findings.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Next Release Backlog

Development

Successfully merging this pull request may close these issues.

Setup throws NullPointerException when enableMongoChallenge or unsafeLevels is absent

2 participants