Skip to content

Conversation

@aaryan359
Copy link
Contributor

@aaryan359 aaryan359 commented Feb 1, 2026

This PR replaces several panic() calls with proper error handling across Jaeger CLI tools, improving robustness and preventing unexpected runtime crashes.

Which problem is this PR solving?

Description of the changes

  • Replaced panic(err) with error returns in InitFromViper methods
    • cmd/es-rollover/app/flags.go
    • cmd/es-index-cleaner/app/flags.go
  • Updated ParseJaegerTags to return an error for invalid tag pairs
    • cmd/internal/flags/flags.go
  • Updated all callers to properly handle returned errors
    • cmd/es-index-cleaner/main.go
    • cmd/es-rollover/app/actions.go
  • Updated and extended tests to assert error conditions instead of panics
    • cmd/es-rollover/app/flags_test.go
    • cmd/es-index-cleaner/app/flags_test.go
    • cmd/internal/flags/flags_test.go

These changes align with Go best practices and improve CLI stability without changing functionality.

How was this change tested?

  • make fmt
  • make lint
  • make test

All tests pass successfully.

Checklist

  • I have read the contributing guidelines
  • I have signed all commits
  • I have added/updated unit tests where applicable
  • I have run lint and test steps successfully

- Replace panic(err) with error returns in InitFromViper methods
  - cmd/es-rollover/app/flags.go: Return error from InitFromViper
  - cmd/es-index-cleaner/app/flags.go: Return error from InitFromViper

- Replace panic with error return in ParseJaegerTags
  - cmd/internal/flags/flags.go: Return error for invalid tag pairs

- Replace panic with proper error handling in tracegen
  - cmd/tracegen/main.go: Handle logger creation error gracefully

- Update all callers to handle returned errors
  - cmd/es-index-cleaner/main.go: Check InitFromViper error
  - cmd/es-rollover/app/actions.go: Check InitFromViper error
  - cmd/es-rollover/app/flags_test.go: Update test assertions
  - cmd/es-index-cleaner/app/flags_test.go: Update test assertions
  - cmd/internal/flags/flags_test.go: Update tests for error handling

This improves error handling and prevents runtime crashes by properly
propagating errors instead of panicking.

Signed-off-by: aaryan359 <aaryanmeena96@gmail.com>
@aaryan359 aaryan359 requested a review from a team as a code owner February 1, 2026 20:21
@dosubot
Copy link

dosubot bot commented Feb 1, 2026

Related Documentation

No published documentation to review for changes on this repository.

Write your first living document

How did I do? Any feedback?  Join Discord

@dosubot dosubot bot added the go Pull requests that update go code label Feb 1, 2026
Signed-off-by: aaryan359 <aaryanmeena96@gmail.com>
@aaryan359
Copy link
Contributor Author

@yurishkuro,
I’ve updated the tests as suggested and restored the panic in tracegen/main.go.
Please let me know if there’s anything else to tweak.

@yurishkuro yurishkuro added changelog:bugfix-or-minor-feature changelog:refactoring Internal code refactoring without functional changes and removed changelog:bugfix-or-minor-feature labels Feb 1, 2026
@yurishkuro yurishkuro enabled auto-merge February 1, 2026 22:11
@codecov
Copy link

codecov bot commented Feb 1, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.58%. Comparing base (2d4e012) to head (d3ed4df).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7956   +/-   ##
=======================================
  Coverage   95.58%   95.58%           
=======================================
  Files         316      316           
  Lines       16763    16766    +3     
=======================================
+ Hits        16023    16026    +3     
- Misses        578      579    +1     
+ Partials      162      161    -1     
Flag Coverage Δ
badger_v1 9.16% <ø> (ø)
badger_v2 1.89% <ø> (ø)
cassandra-4.x-v1-manual 13.36% <ø> (ø)
cassandra-4.x-v2-auto 1.88% <ø> (ø)
cassandra-4.x-v2-manual 1.88% <ø> (ø)
cassandra-5.x-v1-manual 13.36% <ø> (ø)
cassandra-5.x-v2-auto 1.88% <ø> (ø)
cassandra-5.x-v2-manual 1.88% <ø> (ø)
clickhouse 1.97% <ø> (ø)
elasticsearch-6.x-v1 17.20% <ø> (ø)
elasticsearch-7.x-v1 17.23% <ø> (ø)
elasticsearch-8.x-v1 17.38% <ø> (ø)
elasticsearch-8.x-v2 1.89% <ø> (ø)
elasticsearch-9.x-v2 1.89% <ø> (ø)
grpc_v1 8.41% <ø> (ø)
grpc_v2 1.89% <ø> (ø)
kafka-3.x-v2 1.89% <ø> (ø)
memory_v2 1.89% <ø> (ø)
opensearch-1.x-v1 17.27% <ø> (ø)
opensearch-2.x-v1 17.27% <ø> (ø)
opensearch-2.x-v2 1.89% <ø> (ø)
opensearch-3.x-v2 1.89% <ø> (ø)
query 1.89% <ø> (ø)
tailsampling-processor 0.54% <ø> (ø)
unittests 94.27% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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.

@aaryan359
Copy link
Contributor Author

@yurishkuro thanks for the review!
I noticed a small coverage change due to the new error-handling paths — let me know if you’d like me to add tests for those cases, happy to do so.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR improves CLI robustness by removing panic()-based error handling and replacing it with returned/propagated errors that can be handled gracefully by callers.

Changes:

  • Updated ParseJaegerTags to return (map[string]string, error) and added tests for invalid tag inputs.
  • Updated es-rollover and es-index-cleaner configs to return errors from InitFromViper instead of panicking, and updated callers/tests to handle these errors.
  • Adjusted tests to assert error behavior rather than panic behavior.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
cmd/internal/flags/flags.go ParseJaegerTags now returns an error instead of panicking on invalid input.
cmd/internal/flags/flags_test.go Updated tests to validate error returns and added invalid-input coverage.
cmd/es-rollover/app/flags.go Config.InitFromViper now returns an error instead of panicking on TLS init failure.
cmd/es-rollover/app/actions.go Propagates InitFromViper errors with context instead of assuming no-fail initialization.
cmd/es-rollover/app/flags_test.go Updated to assert InitFromViper succeeds via require.NoError.
cmd/es-index-cleaner/app/flags.go Config.InitFromViper now returns an error instead of panicking on TLS init failure.
cmd/es-index-cleaner/main.go Caller now handles InitFromViper errors and returns them from the command.
cmd/es-index-cleaner/app/flags_test.go Updated to assert InitFromViper succeeds via require.NoError.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +42 to 45
func ParseJaegerTags(jaegerTags string) (map[string]string, error) {
if jaegerTags == "" {
return nil
return nil, nil
}
Copy link

Copilot AI Feb 2, 2026

Choose a reason for hiding this comment

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

PR description states that cmd/tracegen/main.go was updated to replace the logger-creation panic with graceful stderr reporting, but that change is not present in this PR’s diffs. Either include the cmd/tracegen/main.go update (it currently still panics on logger build failure) or adjust the PR description/scope so it matches the actual changes.

Copilot uses AI. Check for mistakes.
Signed-off-by: aaryan359 <aaryanmeena96@gmail.com>
auto-merge was automatically disabled February 2, 2026 13:48

Head branch was pushed to by a user without write access

@aaryan359
Copy link
Contributor Author

@jkowall, now i fixed the test coverage and fixed the description also . can this meged now

Signed-off-by: aaryan359 <aaryanmeena96@gmail.com>
@yurishkuro yurishkuro enabled auto-merge February 3, 2026 03:38
@yurishkuro yurishkuro added this pull request to the merge queue Feb 3, 2026
Merged via the queue into jaegertracing:main with commit dc94e83 Feb 3, 2026
61 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog:refactoring Internal code refactoring without functional changes go Pull requests that update go code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[chore]: Replace panic() calls with proper error handling

2 participants