-
Notifications
You must be signed in to change notification settings - Fork 3
fix: add validation for malformed headers in metrics module and add unit tests #383
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
Conversation
…s to the OTEL config
…nit tests Co-Authored-By: maxence@formance.com <maxence@formance.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Co-Authored-By: maxence@formance.com <maxence@formance.com>
@coderabbitai review |
headersMap := make(map[string]string) | ||
for _, header := range otelMetricsExporterOTLPHeaders { | ||
parts := strings.SplitN(header, "=", 2) | ||
if len(parts) == 2 { |
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.
Handle the case where len(parts) == 1
Co-Authored-By: maxence@formance.com <maxence@formance.com>
otlp/otlpmetrics/cli.go
Outdated
if len(parts) == 2 { | ||
headersMap[parts[0]] = parts[1] | ||
} else if len(parts) == 1 { | ||
continue |
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.
Trigger an error...
Co-Authored-By: maxence@formance.com <maxence@formance.com>
otlp/otlpmetrics/cli.go
Outdated
if len(parts) == 2 { | ||
headersMap[parts[0]] = parts[1] | ||
} else if len(parts) == 1 && parts[0] != "" { | ||
panic("malformed header: " + header + " (missing value)") |
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.
Damn, just return a CLI error
Co-Authored-By: maxence@formance.com <maxence@formance.com>
otlp/otlpmetrics/cli.go
Outdated
if len(parts) == 2 { | ||
headersMap[parts[0]] = parts[1] | ||
} else if len(parts) == 1 && parts[0] != "" { | ||
cmd.PrintErrf("Error: malformed header: %s (missing value)\n", header) |
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.
Don't print the error
Co-Authored-By: maxence@formance.com <maxence@formance.com>
Co-Authored-By: maxence@formance.com <maxence@formance.com>
Closing due to inactivity for more than 7 days. |
This PR addresses issues identified in PR #333:
Link to Devin run: https://app.devin.ai/sessions/3d6fd518f5a5497cb18d40cbfdb321e6
Requested by: maxence@formance.com