Skip to content

Validate main registry/query URLs against library instance list#461

Merged
tkuhn merged 1 commit into
masterfrom
validate-main-urls-against-library
May 13, 2026
Merged

Validate main registry/query URLs against library instance list#461
tkuhn merged 1 commit into
masterfrom
validate-main-urls-against-library

Conversation

@tkuhn
Copy link
Copy Markdown
Contributor

@tkuhn tkuhn commented May 13, 2026

Summary

  • Cross-check NANODASH_MAIN_REGISTRY / NANODASH_MAIN_QUERY against the nanopub library's discovered instance list (NanopubServerUtils.getRegistryServerList() / QueryCall.getApiInstances()) instead of trusting the env var blindly. When the env value isn't in the list, fall back to the first known instance and log a warning.
  • Cache the resolved URLs for the JVM lifetime (double-checked locking) and warm them at startup via Utils.initMainUrls() from WicketApplication.init(), so the (potentially slow) discovery is paid once at boot instead of on the first user request.
  • Drop the now-redundant Utils.getMainRegistryUrl() argument passed to PublishNanopub.publish(...) in PublishForm and PreviewPage — let the library use its own default.

Resolution rules

  • Env var set and matches a library instance → use it (validated).
  • Env var set, library list empty → use it unvalidated (warn).
  • Env var set but no match → warn and fall back to first library instance.
  • Env var unset, library list non-empty → use first library instance.
  • Env var unset, library list empty → built-in default (warn).

URL comparison is normalised (trim, strip trailing slash, lowercase); results are returned with a trailing slash.

Test plan

  • Boot nanodash with no NANODASH_MAIN_* env vars; confirm logs report library-discovered URLs and the app reaches the registry.
  • Boot with NANODASH_MAIN_REGISTRY set to a known library instance; confirm "validated against library instance list" log line.
  • Boot with NANODASH_MAIN_REGISTRY set to a bogus URL; confirm warn log and fallback to first library instance.
  • Publish a nanopub via the publish form and via the preview page; confirm both succeed without the explicit registry URL.

🤖 Generated with Claude Code

Cross-check NANODASH_MAIN_REGISTRY / NANODASH_MAIN_QUERY against the
nanopub library's discovered instance list and fall back to the first
known instance when the env value is unknown. Cache the resolved URLs
for the JVM lifetime and warm them at startup so discovery cost is paid
once, not on the first user request. Drop the now-redundant explicit
registry URL passed to PublishNanopub.publish at the two call sites.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@tkuhn tkuhn merged commit b4a740b into master May 13, 2026
8 checks passed
@tkuhn tkuhn deleted the validate-main-urls-against-library branch May 13, 2026 09:40
@github-actions
Copy link
Copy Markdown

🎉 This PR is included in version 4.28.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant