Skip to content

fix(config): let an explicitly configured main registry/query URL win - #685

Merged
tkuhn merged 1 commit into
masterfrom
fix/680-explicit-main-url-wins
Sep 4, 2026
Merged

fix(config): let an explicitly configured main registry/query URL win#685
tkuhn merged 1 commit into
masterfrom
fix/680-explicit-main-url-wins

Conversation

@tkuhn

@tkuhn tkuhn commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Closes #680.

The bug

Utils.resolveMainUrl validated NANODASH_MAIN_REGISTRY / NANODASH_MAIN_QUERY against the instance list discovered by nanopub-java, and replaced the configured URL with the first library instance when it did not appear there:

logger.warn("{}={} is not in the library instance list {}; falling back to first library instance", ...);
return ensureTrailingSlash(instances.get(0));

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_INSTANCES were 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/probeQuery and ServiceHealth.checkQuery/checkRegistry also 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.
  • New MainUrlResolutionTest (6 cases): private URL outside the list survives, trailing-slash normalisation, empty list, in-list value, unset-with-list, unset-with-empty-list. resolveMainUrl is 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

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
@tkuhn
tkuhn merged commit 15ec6a2 into master Sep 4, 2026
7 checks passed
@tkuhn
tkuhn deleted the fix/680-explicit-main-url-wins branch September 4, 2026 14:02
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.

NANODASH_MAIN_REGISTRY / NANODASH_MAIN_QUERY are silently discarded when the URL is not in the library instance list

1 participant