Skip to content

fix(builder): one resource per plugin endpoint instead of one per plugin (#202) - #204

Merged
thomaschristory merged 2 commits into
mainfrom
fix/plugin-resource-collapse
Oct 24, 2026
Merged

thomaschristory merged 2 commits into
mainfrom
fix/plugin-resource-collapse

Conversation

@thomaschristory

Copy link
Copy Markdown
Owner

Fixes #202.

NetBox tags every plugin endpoint plugins. _resource_from_path anchored on that segment, so the resource became the plugin name, and all of a plugin's endpoints collapsed into one resource whose CRUD slots overwrote each other. On NetBox 4.7.3 with netbox-branching 1.2.2:

  • nsc plugins branching list listed changes, while create created branches.
  • Listing and getting branches was unreachable, and so were branch-events and branchable-models.

The documented case (a plugin with its own tag, /api/plugins/my-plugin/widgets/) was broken the same way.

Fix (nsc/builder/build.py):

  • The new _plugin_route maps /api/plugins/<plugin>/<resource>/… to (plugin, resource). The plugin root view /api/plugins/<plugin>/ is skipped.
  • The generic plugins tag becomes the plugin's URL segment. A plugin that sets its own tag keeps it.
  • MODEL_FORMAT_VERSION 1 → 2, so cached command models rebuild. They're keyed by schema hash, so they'd otherwise keep the broken tree.

Resulting tree (live, NetBox 4.7.3 + Branching 1.2.2):

nsc branching {branches,changes,branch-events,branchable-models}
nsc branching branches {list,get,create,update,replace,delete,archive-create,merge-create,recover-create,revert-create,sync-create}

nsc ls branches resolves the plugin resource.

⚠️ Command paths change for plugin users: nsc plugins <plugin> … → nsc <plugin> <resource> …. The old tree was mixing objects, so this ships as a fix, with the change called out in the CHANGELOG.

Tests:

  • tests/builder/test_plugin_paths.py:
    • the generic tag is mapped to the plugin;
    • per-resource ops stay separate;
    • a plugin's own tag is kept;
    • two plugins stay separate;
    • the root view is skipped.
  • tests/e2e/test_branching.py: a new live test lists branches via nsc branching branches list. It also checks that nsc branching changes list --branch <schema_id> filters to the branch's change without switching into the branch (no ⎇ notice). This is the e2e assertion deferred from test: end-to-end coverage for subcommand --branch query filter (#170 scenario) #180. It passed locally on the e2e-branching stack: 4 passed.

Docs: docs/guides/working-with-plugins.md, CHANGELOG.

https://claude.ai/code/session_01RD8NgCVtp3yYFd6NSZpbUb

…gin (#202)

NetBox tags every plugin endpoint `plugins`, so _resource_from_path took
the plugin name as the resource and every endpoint of a plugin collapsed
into one resource whose CRUD slots overwrote each other (`nsc plugins
branching list` listed changes, `create` created branches; branch lists,
branch-events and branchable-models were unreachable).

Derive (plugin, resource) from /api/plugins/<plugin>/<resource>/ paths;
the generic `plugins` tag becomes the plugin's URL segment, a plugin's
own tag is kept. Bump MODEL_FORMAT_VERSION so cached models rebuild.

Also adds the live e2e assertion deferred from #180: `nsc branching
changes list --branch <schema_id>` filters without switching branch.

Claude-Session: https://claude.ai/code/session_01RD8NgCVtp3yYFd6NSZpbUb
_build_fk_resources parsed paths without the plugin route, so plugin
serializers never mapped to a resource and TUI FK pickers could not
resolve plugin targets. Share one `_route` helper between _assimilate
and the FK index.

Claude-Session: https://claude.ai/code/session_01RD8NgCVtp3yYFd6NSZpbUb
@thomaschristory

Copy link
Copy Markdown
Owner Author

Pushed 128a46a: review found plugin list serializers weren't indexed for FK resolution (_build_fk_resources bypassed the plugin route). Both now share _route; test added.

@thomaschristory
thomaschristory merged commit 8ba6557 into main Oct 24, 2026
15 checks passed
@thomaschristory
thomaschristory deleted the fix/plugin-resource-collapse branch October 24, 2026 21:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Plugin endpoints collapse into one resource per plugin (tag 'plugins'): ops overwrite each other

1 participant