Skip to content

Add tests for Sidekiq::JobRecord parsing and display contracts#7028

Merged
mperham merged 1 commit into
sidekiq:mainfrom
hammadxcm:test-job-record-substantive-behaviors
Jun 4, 2026
Merged

Add tests for Sidekiq::JobRecord parsing and display contracts#7028
mperham merged 1 commit into
sidekiq:mainfrom
hammadxcm:test-job-record-substantive-behaviors

Conversation

@hammadxcm

Copy link
Copy Markdown
Contributor

Summary

Four cohesive tests covering substantive JobRecord behavior that the existing API tests only touched indirectly through specific Queue/ScheduledSet flows:

  • Malformed Redis payload — a JobRecord.new("not-json", "default") doesn't raise; item is {}, args expose the raw string for Web UI display, klass is nil. This is the recovery path in JobRecord#parse's rescue JSON::ParserError.
  • Encrypted arguments — when self["encrypt"] is truthy, display_args redacts the final positional argument to "[encrypted data]" so secrets aren't surfaced to the Web UI.
  • Hash payload — passed through to #item without re-parsing (the common path from Queue#each etc.).
  • JSON string payload — parsed into the item hash and exposes klass and args.

Test-only, no lib/ changes.

Testing

bundle exec rake is green (standard + lint:herb + full suite).

Four cohesive tests covering substantive, user-facing JobRecord behavior
that the existing api_test only touched indirectly:

- A malformed Redis payload is rendered safely instead of raising:
  item is {}, args expose the raw string, klass is nil.
- The encrypt flag redacts the final positional argument to
  '[encrypted data]' in display_args.
- A Hash payload is passed through to #item without re-parsing.
- A JSON string payload is parsed into the item hash and exposes klass
  and args.
@mperham mperham merged commit a02f5f8 into sidekiq:main Jun 4, 2026
17 checks passed
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

Successfully merging this pull request may close these issues.

2 participants