fix(ingester): don't clear a cluster's scope oneof when building a VirtualMachine - #111
Merged
Merged
Conversation
…rtualMachine
VirtualMachine(cluster=..., site=...) filled the cluster's scope_site whenever
HasField("scope_site") was False. Cluster.scope is a oneof, so that guard is
also False when the caller already scoped the cluster to a SiteGroup, Location
or Region, and CopyFrom then silently cleared it.
ingester.py is regenerated output: this is the artifact produced by the
generator fix in netboxlabs/eng-observability-skunkworks#57, whose only change
over the current NetBox v4.7.0 generation is that guard.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Coverage Report
|
||||||||||||||||||||||||||||||||||||||||
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The fix is narrowly scoped and includes regression coverage for the affected behavior.
Pull request overview
Fixes VM cluster shortcut handling to preserve existing cluster scope oneof values.
Changes:
- Uses
WhichOneof("scope")before populatingscope_site. - Adds regression coverage for existing
SiteGroupscope.
File summaries
| File | Summary |
|---|---|
tests/test_ingester.py |
Verifies existing cluster scope is preserved. |
netboxlabs/diode/sdk/ingester.py |
Applies the oneof-aware guard. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
ldrozdz93
marked this pull request as ready for review
September 11, 2026 07:48
ldrozdz93
requested review from
davidlanouette,
jajeffries,
leoparente,
manrodrigues,
mfiedorowicz,
paulstuart and
samiura
as code owners
September 11, 2026 07:48
jajeffries
approved these changes
Sep 11, 2026
mfiedorowicz
approved these changes
Sep 11, 2026
|
🎉 This PR is included in version 1.14.1 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
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.
Problem
VirtualMachine(cluster=…, site=…)writesscope_siteinto the caller'sClustermessage.Cluster.scopeis a protobufoneof, so that write silently deletes whatever scope the caller had already set — a SiteGroup, Location or Region.The guard was
not cluster.HasField("scope_site"), which isFalsewhile a sibling of the oneof holds the scope, so the write went ahead andCopyFromcleared the sibling.Fix
ingester.pyis generated code. This is the artifact regenerated from netboxlabs/eng-observability-skunkworks#57, which taught the generator to guard a shortcut target belonging to a oneof withWhichOneof(<oneof>)instead ofHasField(<field>). Over the current NetBox v4.7.0 generation that is a single line:WhichOneofsubsumes the old check, so an unscoped cluster is still filled from the VM's site and an already-scoped one is left alone. The other 19 shortcut writes target fields outside a oneof and are unchanged.Adds a regression test for the case that was failing.
Closes OBS-3803.
🤖 Generated with Claude Code