Skip to content

🐛 Fix GCP network/subnetwork discovery not working + several crashes#6675

Merged
tas50 merged 5 commits intomainfrom
tas50/gcp_fixes
Mar 11, 2026
Merged

🐛 Fix GCP network/subnetwork discovery not working + several crashes#6675
tas50 merged 5 commits intomainfrom
tas50/gcp_fixes

Conversation

@tas50
Copy link
Copy Markdown
Member

@tas50 tas50 commented Feb 24, 2026

A few different issues here.

  • Fix some crashes I experienced trying to list out networks + a few other places where we weren't doing nil checks
  • Get discovery of networks/subnetworks working
  • Update the deps to the latest
  • Don't make the individual resources private since we have asset platforms for these

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 24, 2026

Test Results

5 397 tests  ±0   5 393 ✅ ±0   2m 7s ⏱️ -1s
  411 suites ±0       4 💤 ±0 
   31 files   ±0       0 ❌ ±0 

Results for commit 4659a28. ± Comparison against base commit 95f5fbc.

♻️ This comment has been updated with latest results.

Copy link
Copy Markdown

@mondoo-code-review mondoo-code-review bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well-implemented crash fixes with proper nil checks and improved resource fetching

@tas50 tas50 changed the title 🐛 Fix 2 crashes in the gcp provider 🐛 Fix GCP network/subnetwork discovery not working + several crashes Feb 24, 2026
Copy link
Copy Markdown

@mondoo-code-review mondoo-code-review bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Critical compilation error in subnetwork fallback; missing nil checks in fallback paths

Additional findings (file/line not in diff):

  • 🟡 providers/gcp/resources/compute.go:1371 — Missing nil checks before accessing args["name"], args["region"], and args["projectId"]. If these keys are absent, this will panic with nil pointer dereference.

@tas50
Copy link
Copy Markdown
Member Author

tas50 commented Feb 25, 2026

Regarding the bot review (CHANGES_REQUESTED):

  • "Undefined variable region" — Not an issue. region is defined at the top of initGcpProjectComputeServiceSubnetwork (line 1453) before both the cache lookup and the fallback path.
  • "Missing nil checks on args" (lines 1321, 1371, 1505) — This follows the established pattern across all GCP init functions. When len(args) == 0, the values are populated from getAssetIdentifier (or an error is returned). When len(args) > 0, the MQL framework always provides the args defined in the .lr schema. No existing init function in the GCP provider adds nil guards here.

@tas50 tas50 added the pending-testing Waiting on manual testing label Feb 28, 2026
tas50 and others added 4 commits March 11, 2026 10:30
Signed-off-by: Tim Smith <tsmith84@gmail.com>
This makes the discover actually work

Signed-off-by: Tim Smith <tsmith84@gmail.com>
Signed-off-by: Tim Smith <tsmith84@gmail.com>
GetInstances() already enumerates all instances across all zones.
If the instance isn't found in that list, a direct Get call won't
find it either. Keep the fallback only for network/subnetwork init
where it's needed for discovery and shared VPC scenarios.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@tas50 tas50 force-pushed the tas50/gcp_fixes branch from d0464ff to 73c8108 Compare March 11, 2026 17:33
@mondoo-code-review mondoo-code-review bot dismissed their stale review March 11, 2026 17:33

Superseded by new review

Copy link
Copy Markdown

@mondoo-code-review mondoo-code-review bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GCP network/subnetwork discovery and several nil-pointer crashes are fixed, but a bug check on gvnic config was also corrected.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@tas50 tas50 merged commit e92d14d into main Mar 11, 2026
21 checks passed
@tas50 tas50 deleted the tas50/gcp_fixes branch March 11, 2026 18:47
@github-actions github-actions bot locked and limited conversation to collaborators Mar 11, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

pending-testing Waiting on manual testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants