Skip to content
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

Logging::Middleware.context can include empty string as key when lock is not set in job hash #785

Closed
ttstarck opened this issue May 26, 2023 · 1 comment

Comments

@ttstarck
Copy link
Contributor

ttstarck commented May 26, 2023

Describe the bug
Logs produced within the Middleware Logging context can contain an empty string as a key for jobs without "lock" key set in the job_hash. "" as a key within the log context at the moment is causing these logs to not be able to be ingested into our logging backend (Elasticsearch).

Expected behavior
Logs produced within the Middleware Logging context properly sets the lock type used within the log context.

Current behavior
Logs produced within the Middleware Logging context includes "" => digest but doesn't include any context on what lock is being used.

Additional context
The unique_disabled? check will return true, even if item[LOCK] is false, if the job class' sidekiq_options contain a lock.

However, the middleware logging context, called right after, assumes that item[LOCK] is set, and uses it as the key within the logging_context method

Two possible solutions for this bug:

  1. Don't include the lock type within the log context if item[LOCK] is nil.
  2. Add the lock to the job hash when we prepare the job.

My vote would be to go with Solution 2 as I could forsee other bugs coming up due to an assumption that item[LOCK] exists.

PR for Solution 2, but happy to hear other possible solutions.

@ttstarck
Copy link
Contributor Author

Fix is merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant