Fix NoMethodError in JobWebhook when error is nil#222
Merged
sebastianMindee merged 2 commits intomindee:mainfrom Feb 5, 2026
Merged
Fix NoMethodError in JobWebhook when error is nil#222sebastianMindee merged 2 commits intomindee:mainfrom
sebastianMindee merged 2 commits intomindee:mainfrom
Conversation
sebastianMindee
requested changes
Feb 5, 2026
Collaborator
sebastianMindee
left a comment
There was a problem hiding this comment.
First off, thank you very much for taking the time to do this. The vast majority of people don't care enough to help, so this is like a breath of fresh air.
Secondly, there is a couple of issue with the PR I'd like you to fix if possible:
- The error checks don't need to account for
{}. Both in the test and the constructor. - The error type is correct in the docstring but invalid in steep (my bad), can you update it? should be
attr_reader error: ErrorResponse?instead ofattr_reader error: ErrorResponseinsig/mindee/parsing/v2/job_webhook.rbs. - The linting checks are failing for me. Please run
bundle exec rubocop -Abefore committing.
Once done, I can release later today or tomorrow at the latest if all goes well.
Thank you!
spec/v2/parsing/job_webhook_spec.rb
Outdated
| server_response = { | ||
| 'id' => '12345678-1234-1234-1234-123456789012', | ||
| 'status' => 'Processing', | ||
| 'error' => {} |
Collaborator
There was a problem hiding this comment.
Should never happen. And I think it would be important for this to break if an unexpected error was loaded.
lib/mindee/parsing/v2/job_webhook.rb
Outdated
Comment on lines
26
to
28
| unless server_response['error'].nil? || server_response['error'].empty? | ||
| @error = ErrorResponse.new(server_response['error']) | ||
| end |
Collaborator
There was a problem hiding this comment.
Suggested change
| unless server_response['error'].nil? || server_response['error'].empty? | |
| @error = ErrorResponse.new(server_response['error']) | |
| end | |
| unless server_response['error'].nil? | |
| @error = ErrorResponse.new(server_response['error']) | |
| end |
Empty error shouldn't be possible. Only valid objects or null.
sebastianMindee
approved these changes
Feb 5, 2026
Collaborator
sebastianMindee
left a comment
There was a problem hiding this comment.
Amazing thanks 🙏
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix
NoMethodErrorinJobWebhook#initializewhen theerrorkey is present but value isnil.Problem
When the API returns a response like:
{"id": "12345678-1234-1234-1234-123456789012", "status": "Processing", "error": null} The JobWebhook initializer would call ErrorResponse.new(nil), causing: NoMethodError: undefined method '[]' for nil Solution Updated JobWebhook#initialize to match the existing pattern in Job#initialize: unless server_response['error'].nil? || server_response['error'].empty? @error = ErrorResponse.new(server_response['error']) end Test plan - Added unit tests for JobWebhook covering all edge cases <img width="1460" height="352" alt="PR_description_img" src="https://github.com/user-attachments/assets/64591692-8d35-4d88-9b43-ef0596d717de" />