Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Stop server startup when no server base url [DHIS2-17980] #18580

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,13 @@ public void init() {
this.properties.setProperty(
"connection.dialect", "org.hisp.dhis.hibernate.dialect.DhisPostgresDialect");

// ---------------------------------------------------------------------
// If mandatory config is not present stop startup
// ---------------------------------------------------------------------
String serverBaseUrl = this.properties.getProperty(ConfigurationKey.SERVER_BASE_URL.getKey());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a thought: I assume there are other required configs. Could we declare that in ConfigurationKey with a boolean required and fail startup if any of these required ones without a default have no value? We might awkwardly fail at some later point when a user triggers code reading the config key for the first time 😅

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, that's a good idea for a new feature. This PR has fallen through the cracks. Hope to get back to this smaller fix before the release.

if (serverBaseUrl == null)
throw new IllegalStateException("server.base.url value is required on startup");

// ---------------------------------------------------------------------
// Load Google JSON authentication file into properties bundle
// ---------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ monitoring.api.enabled = off
enable.query.logging = true
method.query.logging.enabled = false
system.remote_servers_allowed = https://validtesturl.com/,https://validtesturl2.com/
server.base.url = localhost:8080


2 changes: 2 additions & 0 deletions dhis-2/dhis-test-e2e/config/dhis2_home/dhis.conf
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ audit.logger=off

# Analytics configuration
analytics.table.unlogged = on

server.base.url = localhost:8080
Loading