[client] Include MTU and SSH auth config in debug bundle#6071
Conversation
📝 WalkthroughWalkthroughThe pull request extends the debug bundle configuration output to include two SSH-related fields ( ChangesDebug Bundle Configuration Expansion
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
client/internal/debug/debug_test.go (1)
838-841: ⚡ Quick winAvoid test-side duplication of
addConfigrendering logic.Line 867 introduces a parallel renderer (
renderAddConfigSpecific) that can drift fromaddConfig()and hide regressions. Prefer renderingconfig.txtby callingaddConfig()and asserting against the produced archive content.♻️ Proposed refactor
- var sb strings.Builder - g.addCommonConfigFields(&sb) - rendered := sb.String() + renderAddConfigSpecific(g) + rendered := renderConfigTxtViaAddConfig(t, g) @@ -func renderAddConfigSpecific(g *BundleGenerator) string { - var sb strings.Builder - if g.anonymize { - if g.internalConfig.ManagementURL != nil { - sb.WriteString("ManagementURL: " + g.anonymizer.AnonymizeURI(g.internalConfig.ManagementURL.String()) + "\n") - } - if g.internalConfig.AdminURL != nil { - sb.WriteString("AdminURL: " + g.anonymizer.AnonymizeURI(g.internalConfig.AdminURL.String()) + "\n") - } - sb.WriteString("NATExternalIPs: x\n") - if g.internalConfig.CustomDNSAddress != "" { - sb.WriteString("CustomDNSAddress: " + g.anonymizer.AnonymizeString(g.internalConfig.CustomDNSAddress) + "\n") - } - } else { - if g.internalConfig.ManagementURL != nil { - sb.WriteString("ManagementURL: " + g.internalConfig.ManagementURL.String() + "\n") - } - if g.internalConfig.AdminURL != nil { - sb.WriteString("AdminURL: " + g.internalConfig.AdminURL.String() + "\n") - } - sb.WriteString("NATExternalIPs: x\n") - if g.internalConfig.CustomDNSAddress != "" { - sb.WriteString("CustomDNSAddress: " + g.internalConfig.CustomDNSAddress + "\n") - } - } - return sb.String() -} +func renderConfigTxtViaAddConfig(t *testing.T, g *BundleGenerator) string { + t.Helper() + + var buf bytes.Buffer + zw := zip.NewWriter(&buf) + g.archive = zw + require.NoError(t, g.addConfig()) + require.NoError(t, zw.Close()) + + zr, err := zip.NewReader(bytes.NewReader(buf.Bytes()), int64(buf.Len())) + require.NoError(t, err) + for _, f := range zr.File { + if f.Name != "config.txt" { + continue + } + rc, err := f.Open() + require.NoError(t, err) + defer rc.Close() + b, err := io.ReadAll(rc) + require.NoError(t, err) + return string(b) + } + t.Fatal("config.txt not found in archive") + return "" +}Also applies to: 867-893
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@client/internal/debug/debug_test.go` around lines 838 - 841, The test duplicates addConfig rendering via renderAddConfigSpecific; instead, call the real addConfig() path and assert the produced archive content to avoid drift: remove or stop using renderAddConfigSpecific and have the test invoke addConfig (or the public function that writes config.txt) after addCommonConfigFields (or pass the same inputs used by addConfig), then read the produced config.txt from the generated archive and assert equality against the expected string; update tests referencing renderAddConfigSpecific (and any helper that builds rendered) to use addConfig/addCommonConfigFields and archive inspection so the test exercises the real implementation.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@client/internal/debug/debug_test.go`:
- Around line 838-841: The test duplicates addConfig rendering via
renderAddConfigSpecific; instead, call the real addConfig() path and assert the
produced archive content to avoid drift: remove or stop using
renderAddConfigSpecific and have the test invoke addConfig (or the public
function that writes config.txt) after addCommonConfigFields (or pass the same
inputs used by addConfig), then read the produced config.txt from the generated
archive and assert equality against the expected string; update tests
referencing renderAddConfigSpecific (and any helper that builds rendered) to use
addConfig/addCommonConfigFields and archive inspection so the test exercises the
real implementation.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 4e95271a-8f59-4365-845c-3714c8857cc7
📒 Files selected for processing (2)
client/internal/debug/debug.goclient/internal/debug/debug_test.go
Release artifactsBuilt for PR head
GHCR images (amd64)
This comment is updated by the Release workflow. Artifact links expire according to the workflow retention policy. |
…ebug bundle Upstream's debug-bundle test TestAddConfig_AllFieldsCovered (added in netbirdio#6071) reflection-checks every Config field is either rendered into the bundle or in the excluded map. The four Phase 1+2+3 fields introduced in this PR — ConnectionMode, RelayTimeoutSeconds, P2pTimeoutSeconds, P2pRetryMaxSeconds — must therefore be rendered. Listed at the end of addCommonConfigFields right after the existing LazyConnectionEnabled line, in the same key:value format the test matches against.
…ebug bundle Upstream's debug-bundle test TestAddConfig_AllFieldsCovered (added in netbirdio#6071) reflection-checks every Config field is either rendered into the bundle or in the excluded map. The four Phase 1+2+3 fields introduced in this PR — ConnectionMode, RelayTimeoutSeconds, P2pTimeoutSeconds, P2pRetryMaxSeconds — must therefore be rendered. Listed at the end of addCommonConfigFields right after the existing LazyConnectionEnabled line, in the same key:value format the test matches against.



Describe your changes
Include
MTU,DisableSSHAuth, andSSHJWTCacheTTLin the debug bundle'sconfig.txt. They were settable via CLI/SetConfigbut never dumped, so they were invisible when triaging from a bundle.addCommonConfigFieldsprofilemanager.Configand fails if a new field is added without either rendering it or marking it excluded (sensitive keys, parsed cert pair)Issue ticket number and link
Stack
Checklist
Documentation
Select exactly one:
Internal debug-bundle contents, no user-facing surface.
Docs PR URL (required if "docs added" is checked)
Paste the PR link from https://github.com/netbirdio/docs here:
https://github.com/netbirdio/docs/pull/__
Summary by CodeRabbit
New Features
Tests