fix: use network-based default metadata server in tari publish#125
Conversation
`tari publish` previously fell back to `http://localhost:3000` when no metadata server URL was provided, ignoring the active network. It now resolves the default from the wallet network (same as `tari metadata publish`), and errors out if no default is known. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
ae6d892 to
d1f8209
Compare
There was a problem hiding this comment.
Code Review
This pull request refactors the default metadata server URL resolution by moving the logic into a shared utility function and applying it to the template publishing command. This replaces a hardcoded URL with a network-aware lookup and adds error handling for cases where no default is defined. Feedback suggests that the default URL should be parsed lazily to improve efficiency when the URL is already provided through other configuration sources.
| let resolved_default = get_default_metadata_server_url(&info.network) | ||
| .map(|s| s.parse::<url::Url>().expect("parse default metadata server url")); |
There was a problem hiding this comment.
The default metadata server URL is parsed even if it's not needed (i.e., when a URL is provided via CLI arguments, project config, or global config). While Url::parse is relatively inexpensive for these short, hardcoded strings, it would be more efficient to perform this resolution lazily only when all other configuration sources are None.
Summary
tari publishpreviously hardcodedhttp://localhost:3000as the metadata server fallback, ignoring the active networktari metadata publish) —localnet→ localhost,esmeralda→https://ootle-templates-esme.tari.com/get_default_metadata_server_urlfrommetadata/publish.rsintocli/util.rsso both commands share itTest plan
tari publish --publish-metadataon esmeralda posts to the esmeralda community server (not localhost)tari publish --publish-metadataon localnet still posts tohttp://localhost:3000--metadata-server-urlflag andtari.config.tomlvalue still override the default--metadata-server-url🤖 Generated with Claude Code