Repository navigation
check: treat unknown related hosts as external unless they are this site - #16
Merged
Merged
Conversation
A host at or under the canonical's apex that the map does not name made check exit 2 and advise adding it as an alias. On sites that link to a separate app on their own domain (a login app, a docs site) that refusal blocked unattended init after a db pull, and the alias remedy would have rewritten the app's links onto the local site. check now asks the host first, with bounded requests: it is this site if its root redirects to a hostname the map names, or its /wp-json/ index reports such a home or url. Only then does it refuse as before. Anything else prints a note (saying so explicitly when the host is unreachable) and continues. hostshift.yaml gains an optional per-site external: list that skips the probe and the note. It is validated like the other keys, and a host can't be both external and a hostname the map names. map --external-hosts prints it for the add-on. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
checkused to refuse (exit 2) when a page had 5 or more references to a host at or under the canonical's apex that the map doesn't name, and it told you to add that host as an alias. That's a false positive on sites that link to a separate app on their own domain, such asidentity.example.comor a docs site on another server. It also blocks unattended tooling that runsinitafter a db pull. Following the advice would make things worse, because it rewrites the app's links onto the local site.Change
ddev/commands/host/hostshift,hs_probe_related). Each related unknown host gets bounded requests: 5 s each, at most two same-host redirect hops, never followed onto another host, and the redirect target is read from curl'sredirect_urlrather than fetched. The host counts as this site if its root redirects to a hostname the map names, or ifhttps://<host>/wp-json/reports ahomeorurlthe map names. In that casecheckrefuses as before, with the evidence added to the message.checkprints a note and carries on. If the host can't be reached, the note says "could not reach it; treated as external". The note still points at the alias remedy in case the host really is this site, and namesexternal:.external:per site in hostshift.yaml (internal/config/config.go). Listed hosts are skipped with no probe and no note. Entries can be bare hosts or URLs. Each one is normalised, and the file is refused if a host is also a canonical, base, alias or variant of any site. Typos are still caught byKnownFields.hostshift map --external-hostsprints the list for the add-on.www., skip localhost/.test/.ddev.site.Compatibility
The proxy image reads hostshift.yaml too. A CLI or image released before this key rejects
external:as an unknown field. The README says to add it only once both are on a release that includes it. An older CLI on the host just prints nothing for--external-hosts, so every related host gets probed.Tests
test/addon-command.sh: the fake curl gets a per-host seam (HS_CURL_RELATED=host=redirect:<url>|wp:<home>|app|down). New cells cover: an external app gives a note and exit 0, another WordPress gives a note, an unreachable host gives a note, a redirect to the canonical gives a refusal, a/wp-json/home equal to the canonical gives a refusal, and a host listed inexternal:stays silent and is never fetched. The existing refusal cells now declare that their host is this site.internal/config:TestExternalHostscovers normalisation and dedupe, the alias/external conflict, the conflict with another site's canonical, a non-hostname entry, and a misspelled key.make test-addonall passed (including the poisoned-curl check),go test ./...ok,go vetclean,gofmt -lclean.🤖 Generated with Claude Code