fix(config): let an explicitly configured main registry/query URL win - #685
Merged
Conversation
NANODASH_MAIN_REGISTRY and NANODASH_MAIN_QUERY were validated against the instance list discovered by nanopub-java, and silently replaced by the first library instance when they did not appear in it. Pointing nanodash at a private registry or query service therefore had no effect unless the library lists were set as well, and the substitution was only visible as a log warning. An operator who names a service should not be overruled by a discovered list that only knows the public ones. The configured URL is now always used; the list check remains as a log line, and its warning names the actual remedy (setting NANOPUB_REGISTRY_INSTANCES / NANOPUB_QUERY_INSTANCES to the same service) instead of substituting a public instance. This matters more since the service-mode and service-health probes started reading these URLs: on a restricted deployment they were interrogating a public service, which is exactly where the restricted flag is meant to apply. Document both pairs of variables in NOTES.md, including that the library pair is what governs query dispatch and nanopub retrieval. Closes #680 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LqfrG3VXH5tzWXPvYJzXML
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #680.
The bug
Utils.resolveMainUrlvalidatedNANODASH_MAIN_REGISTRY/NANODASH_MAIN_QUERYagainst the instance list discovered by nanopub-java, and replaced the configured URL with the first library instance when it did not appear there:So pointing an instance at a private registry or query service with those variables alone had no effect — a public instance was used instead, visible only as a log warning. The setting only worked if
NANOPUB_REGISTRY_INSTANCES/NANOPUB_QUERY_INSTANCESwere set too, which was undocumented and the wrong way round.Same shape as Nanopublication/nanopub-java#145, fixed there the same way.
The fix
The configured URL always wins. The instance-list check stays, but as a log line only — and when the URL is not in the list, the warning now names the remedy (set the library variables to the same service) instead of substituting.
Wider reach than the issue records
Since #683 merged,
ServiceMode.probeRegistry/probeQueryandServiceHealth.checkQuery/checkRegistryalso read these URLs — not just link building and the account list. On a restricted deployment the bug meant restricted-mode detection and the health probes were interrogating a public service, i.e. exactly the deployment where the restricted flag matters. Fixed by the same change.Also
NOTES.md: "Pin to a single Nanopub Query instance" → "Pointing nanodash at particular services", documenting both pairs and that the library pair is what actually governs query dispatch and nanopub retrieval/publishing.MainUrlResolutionTest(6 cases): private URL outside the list survives, trailing-slash normalisation, empty list, in-list value, unset-with-list, unset-with-empty-list.resolveMainUrlis package-private for this.Not in scope
Query dispatch (
QueryCall) and nanopub retrieval (GetNanopub/ServerIterator) still read only their own env vars, so a restricted deployment genuinely needs all four variables — that is a nanopub-java-side concern (nanopub-java#126).Testing
Full suite: 1291 tests, 0 failures.
🤖 Generated with Claude Code
https://claude.ai/code/session_01LqfrG3VXH5tzWXPvYJzXML