Skip to content

Conversation

@tstirrat15
Copy link
Contributor

@tstirrat15 tstirrat15 commented Oct 22, 2025

Fixes #2633
Part of #2579

Description

If you have a deeply nested proto object, calling a.GetSet().GetOf().GetGetters() is safer than referencing some.Chain.Of.Properties, because the first will return nil if there's a nil in the chain, where the second will panic. protogetter lints for this and should help address #2579.

Changes

  • Add protogetter linter
  • Run fixes

Testing

Review. See that tests pass.

@tstirrat15 tstirrat15 requested a review from a team as a code owner October 22, 2025 21:42
@github-actions github-actions bot added area/cli Affects the command line area/schema Affects the Schema Language area/api v1 Affects the v1 API area/datastore Affects the storage system area/tooling Affects the dev or user toolchain (e.g. tests, ci, build tools) area/dispatch Affects dispatching of requests labels Oct 22, 2025
@tstirrat15 tstirrat15 force-pushed the enable-protogetter-linter branch from 30f414d to c149d58 Compare October 22, 2025 21:44
@codecov
Copy link

codecov bot commented Oct 22, 2025

Codecov Report

❌ Patch coverage is 89.75932% with 217 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.14%. Comparing base (5d34d05) to head (45d4100).

Files with missing lines Patch % Lines
pkg/proto/dispatch/v1/00_zerolog.go 0.00% 29 Missing ⚠️
internal/services/v1/permissions.go 88.14% 18 Missing and 3 partials ⚠️
internal/services/v1/experimental.go 81.61% 11 Missing and 5 partials ⚠️
internal/services/v1/errors.go 62.50% 8 Missing and 4 partials ⚠️
pkg/datastore/datastore.go 67.57% 7 Missing and 5 partials ⚠️
internal/telemetry/metrics.go 0.00% 8 Missing ⚠️
internal/graph/lookupsubjects.go 85.72% 1 Missing and 6 partials ⚠️
internal/services/v1/schema.go 80.00% 6 Missing and 1 partial ⚠️
internal/graph/check.go 93.34% 2 Missing and 4 partials ⚠️
pkg/schema/typesystem_validation.go 76.00% 6 Missing ⚠️
... and 44 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2638      +/-   ##
==========================================
+ Coverage   79.14%   79.14%   +0.01%     
==========================================
  Files         452      452              
  Lines       46401    46404       +3     
==========================================
+ Hits        36719    36723       +4     
+ Misses       6923     6921       -2     
- Partials     2759     2760       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@tstirrat15 tstirrat15 force-pushed the enable-protogetter-linter branch from c149d58 to e825f57 Compare October 22, 2025 21:50
@miparnisari miparnisari changed the title Enable protogetter linter and run fixes chore: Enable protogetter linter and run fixes Oct 23, 2025
@tstirrat15 tstirrat15 force-pushed the enable-protogetter-linter branch from e825f57 to 3008292 Compare October 23, 2025 16:24
@tstirrat15 tstirrat15 force-pushed the enable-protogetter-linter branch from 3008292 to 45d4100 Compare October 23, 2025 16:32
Copy link
Contributor Author

@tstirrat15 tstirrat15 left a comment

Choose a reason for hiding this comment

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

These are the only two files that I touched manually

Comment on lines -27 to +31
return *written.Counter.Value
counter := written.GetCounter()
if counter == nil {
panic("counter was nil")
}
return counter.GetValue()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a meaningful change - we were actually depending on this to panic if Counter was nil, so the nil-safety fix kinda broke the functionality.

Comment on lines -16 to +17
if result != 0.0 {
t.Errorf("Initial counter value should be 0.0, got %v", result)
}
require.Equal(t, 0.0, result, "Initial counter value should be 0.0")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Refactoring these tests to use require to bring them in line with the rest of the codebase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/api v1 Affects the v1 API area/cli Affects the command line area/datastore Affects the storage system area/dispatch Affects dispatching of requests area/schema Affects the Schema Language area/tooling Affects the dev or user toolchain (e.g. tests, ci, build tools)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Introduce protogetter linter

2 participants