fix: bug: edge-control add_route targets non-existent Caddy server edge — registration succeeds in registry but traffic never routes (#789) #790
No reviewers
Labels
No labels
action
backlog
blocked
bug-report
cannot-reproduce
in-progress
in-triage
needs-triage
prediction/actioned
prediction/dismissed
prediction/unreviewed
priority
rejected
reproduced
tech-debt
underspecified
vision
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: disinto-admin/disinto#790
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/issue-789"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes #789
Changes
add_routetargets non-existent Caddy serveredge— registration succeeds in registry but traffic never routes (#789)- install.sh: use Caddy `servers { name edge }` global option so the emitted Caddyfile produces a predictably-named server - lib/caddy.sh: add `_discover_server_name` that queries the admin API for the first server listening on :80/:443 — add_route and remove_route use dynamic discovery instead of hardcoding `/servers/edge/` - lib/caddy.sh: add_route, remove_route, and reload_caddy now check HTTP status codes (≥400 → return 1 with error message) instead of only checking curl exit code Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>AI Review
Summary
This PR fixes a real bug: (and ) hardcoded the Caddy server name as , but Caddy auto-generates server names (, , …) so the hardcoded path never resolved to a real server. The dynamic discovery in is the correct fix. The HTTP-status checking improvements are also good. One addition in is likely invalid Caddyfile syntax and must be addressed.
Findings
install.sh:238-240:servers { name edge }is not a valid subdirective of the globalserversblock in Caddy's Caddyfile adapter. Valid subdirectives arelistener_wrappers,timeouts,protocols,trusted_proxies, etc. —nameis not one of them. Caddy would reject the config with an "unrecognized directive" error, preventing the service from starting on install. Since_discover_server_name()already solves the routing problem dynamically (and doesn't depend on the name beingedge), this block provides no benefit and only introduces risk. Remove it — or, if naming the server is desired, do it by writing the JSON config directly viacaddy adapt+ a loader, or by using the admin API after startup.What's correct
_discover_server_name()incaddy.sh: correct approach. Querying/config/apps/http/serversand filtering by listen address is robust and independent of how Caddy chooses to name the server.curl -w '\n%{http_code}'+tail -n1/sed '$d': standard pattern, implemented correctly across all three API calls.<<EOF→<<'CADDYEOF': correct — prevents bash from accidentally expanding Caddy placeholder syntax like{env.GANDI_API_KEY}.server_name=$(_discover_server_name) || return 1correctly short-circuits all callers on discovery failure.Verdict
REQUEST_CHANGES — servers { name edge } is not a valid Caddy Caddyfile directive and likely breaks install by preventing Caddy from starting
Reviewed at
987413a| AGENTS.mdAI Review: REQUEST_CHANGES — servers { name edge } is not a valid Caddy Caddyfile directive and likely breaks install by preventing Caddy from starting
servers { name edge }Caddyfile directiveAI Re-review (round 2)
Previous Findings
servers { name edge }invalid Caddyfile directive → FIXED: The block has been removed frominstall.sh:236-238. The Caddyfile now contains only valid directives (admin, site block with TLS). The comment was updated to accurately describe that dynamic discovery is the sole mechanism.What's correct
_discover_server_name()incaddy.sh:24-38: correct and robust.set -euo pipefail(line 14) means thecurl | jqpipeline failure is caught by the||handler.curl -w '\n%{http_code}'+tail -n1/sed '$d') applied consistently to all three API calls.<<'CADDYEOF'heredoc quoting prevents bash from expanding Caddy placeholders like{env.GANDI_API_KEY}.server_name=$(_discover_server_name) || return 1correctly short-circuits all callers.Verdict
APPROVE — The only blocking finding from the previous review (invalid servers { name edge } directive) has been removed; all code is correct.
Reviewed at
241ce96| Previous:987413a| AGENTS.mdAI Re-review (round 2): APPROVE — The only blocking finding from the previous review (invalid servers { name edge } directive) has been removed; all code is correct.