[production][trigger_workflow#create] undefined method 'map' for an instance of String#19435
Draft
sujanyd wants to merge 2 commits intoopenSUSE:masterfrom
Draft
[production][trigger_workflow#create] undefined method 'map' for an instance of String#19435sujanyd wants to merge 2 commits intoopenSUSE:masterfrom
sujanyd wants to merge 2 commits intoopenSUSE:masterfrom
Conversation
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.
Problem
The workflow trigger process would crash with a 500 Internal Server Error (NoMethodError: undefined method 'map' for String) if the .obs/workflows.yml file contained malformed structures. This happened when strings were used instead of expected arrays or hashes in filters or step definitions.
Solution
Model Hardening:
-> Updated Workflowto use Array.wrap for only and ignore branch filters, safely handling both single strings and arrays.
-> Added guards in Workflow#steps to skip non-Hash step definitions early.
-> Updated the ConfigureRepositories step to safely handle malformed repository lists.
Improved Validation:
-> Enhanced WorkflowFiltersValidator and WorkflowStepsValidator to detect incorrect data types and return user-friendly validation errors instead of crashing.
Regression Testing:
-> Added a new spec spec/models/workflow_crash_repro_spec.rb covering various malformed YAML scenarios to ensure the fix is robust.
Verification
-> Verified that malformed YAML now results in a clean error message (e.g., "filter definition is wrong: expected a YAML mapping, got String") instead of a server crash.
-> Confirmed that the fix correctly addresses the NoMethodError reported in the issue.