A malformed marker crashed the courtesy URL, and the hint guessed the port - #93
Merged
Conversation
… port Co-Authored-By: Claude Fable 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.
Three defects in the watch-line plumbing
watch_url()reads.grapharc/live-server.jsonto print the exact live-view URL for a run, andwatch_hint()prints the instruction when no server answers. Three gaps, all found by walking the marker lifecycle:1. Two marker shapes escaped as tracebacks. The tolerant read caught
OSError, ValueError, KeyError— but a marker containing"port": null(int(None)) or a non-object JSON document (indexing a list) raisesTypeError, which flew straight out of a command whose only job at that moment was printing a courtesy URL.TypeErrorjoins the net, so every malformed marker now degrades to the hint.2. The root comparison was asymmetric. The trace side was
.resolve()d, the marker'slive_rootwas trusted verbatim.servedoes write it resolved, but a hand-edited or symlinked spelling of the same directory failed the lexicalrelative_toand silently lost the URL. Both sides resolve now, and the resolve is inside the guarded block (OSErrorincluded).3. The hint hardcoded
http://127.0.0.1:8000. An operator serving on any other port got an instruction quoting a URL their owngrapharc servecommand does not produce. The hint now reads the marker's last-known base URL with the same tolerance (_marker_base()), falling back to the default only when there is no readable marker at all. A stale marker is exactly the case where this matters: the server is down, and the instruction should name the port the operator actually uses.Tests
Three new, in the existing watch-line block of
tests/test_cli.py:test_a_malformed_marker_degrades_to_the_hint_instead_of_crashing— null port and array-shaped marker both returnNone(both raisedTypeErrorbefore).test_an_unresolved_marker_root_still_matches_through_a_symlink— a live listener plus a marker whose root is an unresolved symlink spelling; the URL is produced.test_the_hint_quotes_the_marker_port_when_the_server_is_down— dead port in the marker; the fallback watch line quotes that port, not 8000.The existing pins (exact URL on a live server,
Noneon a stale marker,Noneoutside the root, no-marker instruction with the 8000 default) are untouched and green. Full suite: 1,994 passed, 12 deselected; ruff clean.🤖 Generated with Claude Code