Repository navigation
fix(cli): normalize nbox raw paths to /api/ and reject absolute URLs - #65
Merged
Merged
Conversation
A bare 'raw GET dcim/devices/?limit=1' joined against the base URL and hit the web UI (https://host/dcim/devices/) → HTML → 'expected value at line N', while typed commands worked because their path literals include /api/. normalize_raw_path() now roots the path at /api/ whether the user writes 'dcim/...', 'api/dcim/...', or '/api/dcim/...' (no double api/), and rejects absolute URLs / schemes — Url::join with an absolute input replaces the base, which would send the request off the configured instance. Help text + AGENTS updated; tests cover the three accepted forms, the no-double-prefix case, a colon in a query value, and absolute-URL rejection.
lance0
added a commit
that referenced
this pull request
Jun 22, 2026
Note the navigable device interface/cable tabs (Enter opens the interface detail) and the cable-path A↔Z diagram (naming the device at each end), in the TUI feature bullet, the detail keymap, and the FEATURES TUI section. AGENTS already carries the raw-path note from #65.
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.
The bug
nbox raw GET dcim/devices/?limit=1failed withdecoding NetBox response... expected value at line 8 column 1, while typed commands worked against the same instance.Root cause:
run_rawpasses the path toclient.get→url_fordoesbase_url.join(path.trim_start_matches('/')). A relative path without/api/resolves against the base to the web UI (https://host/dcim/devices/), which returns HTML — hence the JSON decode error at "line 8". Typed commands work because their path literals already include/api/. Confirmed live on 4.6.2:api/dcim/...and/api/dcim/...work; baredcim/...doesn't.The fix
normalize_raw_path()(pure, unit-tested):/api/whether you writedcim/...,api/dcim/..., or/api/dcim/...— without doubling (api/api/).https://…, malformedhttp:/…):Url::joinwith an absolute input replaces the base, which would sendrawoff the configured instance.rawstays path-only against the active profile.Tests (per review)
api/dcim/devices/?limit=1.api/(no double prefix), whitespace trim, a segment merely starting withapi(apiserver/), and a colon in a query value.Help text +
AGENTS.mdupdated. CHANGELOG under[Unreleased](ships with 0.9.0).Verification
fmt · clippy (
--all-features+--no-default-features,-D warnings) · tests both modes — all green. Live: bare path now returns JSON;https://…rejected.