Skip to content

Conversation

@Digvijay-x1
Copy link
Contributor

@Digvijay-x1 Digvijay-x1 commented Dec 5, 2025

Hey friends,

I have tried to fix the 'can't create hash to float' TypeError in the trigger_workflow .

I think that we were previously looping through header keys and performing a lookup for every item, which causes a crash when complex hashes were encountered.

The final logic of the request header remain same but we are now iterating over request.headers.to_h directly as |k, v|, So we can bypass the request.headers[k] and safely process the hash values.

Also please let me know if some test are required to verify the fix.

Fixes : #15699

Thanks !

@github-actions github-actions bot added the Frontend Things related to the OBS RoR app label Dec 5, 2025
@danidoni
Copy link
Contributor

Hey friends,

I have tried to fix the 'can't create hash to float' TypeError in the trigger_workflow .

I think that we were previously looping through header keys and performing a lookup for every item, which causes a crash when complex hashes were encountered.

The final logic of the request header remain same but we are now iterating over request.headers.to_h directly as |k, v|, So we can bypass the request.headers[k] and safely process the hash values.

Also please let me know if some test are required to verify the fix.

Fixes : #15699

Thanks !

Can you provide a test that proves the fix (a test that fails before the fix and that passes after)?

@Digvijay-x1
Copy link
Contributor Author

Hi @danidoni ,

My earlier assumption that the request.header[k] could sometimes contain a complex hash was wrong .

But later I realized that the issue is with the format mention in the

format(workflow_configuration, placeholder_variables)
.

Earlier we had specified to throw a error when "%S" encountered but missed to Added %f which when read by ruby for example format("value: 50%f", variables_hash) it will read the %f and try to convert the other argument which is "variables_hash" to float . Since we cannot convert a key-value pair into a integer , Ruby raised: TypeError: can't convert Hash into Float. .

I Have two ways to fix it , either we can through a error by adding a TypeError similar to "ArgumentError" in

or we can replace format with a regular expression-based substitution using gsub . Which will allow users to have % characters in their YAML files without issues .

I did go with the second option . but I am not sure whether the earlier restrictions were intentional or not .

Here are the test logs I ran ,

=== Reproducing  ===
Testing: "repo: %{SCM_REPOSITORY_NAME}"
Success: "repo: repo"
--------------------
Testing: "value: 50%f"
Failed: TypeError: can't convert Hash into Float

After :

=== Reproducing  ===
Testing: "repo: %{SCM_REPOSITORY_NAME}"
Success: "repo: repo"
--------------------
Testing: "value: 50%f"
Success: "value: 50%f"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Frontend Things related to the OBS RoR app

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[production][trigger_workflow#create] can't convert Hash into Float

2 participants