-
Notifications
You must be signed in to change notification settings - Fork 711
fix: empty user email on grpc metrics ingest #9608
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Failed to generate code suggestions for PR |
Greptile OverviewGreptile SummaryThis PR fixes a critical auth bug where gRPC metrics ingestion could result in empty user emails in usage reporting, and introduces a type-safe Key Changes:
Impact:
Confidence Score: 5/5
Important Files ChangedFile Analysis
Sequence DiagramsequenceDiagram
participant C as Client
participant A as Auth Module
participant H as Handler
participant S as Service
participant R as Reporter
Note over C,R: User Flow
C->>A: Request
A->>A: Check auth
A->>H: Add metadata
H->>H: Create IngestUser
H->>S: Call service
S->>R: Report usage
Note over C,R: System Flow
participant J as Job
J->>H: Request
H->>H: Create IngestUser
H->>S: Call service
S->>R: Report usage
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
17 files reviewed, no comments
YashodhanJoshi1
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm.
Few nits, but can be ignored.
| .unwrap_or_default(); | ||
| .unwrap_or_else(|| { | ||
| log::warn!("[gRPC Metrics] user_id not found in metadata, using empty string"); | ||
| "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: instead of empty string should we use "unknown" ? Not a strong reason, but for some reason that feels better to me. Fine even if kept as is.
|
|
||
| let org_id = org_id.into_inner(); | ||
| let user_email = &user_email.user_id; | ||
| let user = IngestUser::from_user_email(&user_email.user_id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any particular reason here we use this method, but some places directly use IngestUser::User ?
nit: if possible let's use the same thing everywhere
| req_stats.user_email = if email_str.is_empty() { | ||
| None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case instead of None, should we put "unknown" instead?
check auth can return req without populating metadata, this pr fixes the case and adds an
IngestUsertype to mark all system initiated ingestion calls and user initiated ingestion calls