Skip to content

Fix Array<Hash> support for steps#74

Open
emrekutlu wants to merge 1 commit into
transloadit:mainfrom
emrekutlu:main
Open

Fix Array<Hash> support for steps#74
emrekutlu wants to merge 1 commit into
transloadit:mainfrom
emrekutlu:main

Conversation

@emrekutlu
Copy link
Copy Markdown

Hello,

#50 this pull request breaks the support for Array<Hash> support for steps which we came across while trying to upgrade from v2 -> v3.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bb650d11b6

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread lib/transloadit/assembly.rb Outdated
when Transloadit::Step then steps.to_hash
else
if steps.uniq(&:name) != steps
if steps.uniq != steps
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Restore duplicate-name validation for array steps

steps.uniq != steps only detects fully equal elements, so it misses the duplicate-name case this guard is meant to catch (e.g., two hashes keyed by :thumbs with different robot options, or two Step objects with the same name). In those cases no ArgumentError is raised and steps.inject({}) { |h, s| h.update s } silently overwrites the earlier step, changing assembly instructions compared to previous behavior.

Useful? React with 👍 / 👎.

@emrekutlu
Copy link
Copy Markdown
Author

Hi @kvz,

I am not sure what you expect me to do by assigning this to me :)

If this is about the codex comment, that is not correct. uniq under the hood calls eql?, so it still works the same as before for Step. There are existing tests already covering the Step name uniqueness, if someone can run the CI, we can see the results.

Thanks

@kvz
Copy link
Copy Markdown
Member

kvz commented May 18, 2026

Hey @emrekutlu, sorry about the assign. I was experimenting with a tool to ensure all work has an owner. That model works internally, where everybody has the context and can reassign when it guesses wrong, but it should not extend to external contributors like yourself without a note or clarification. I'll adjust the script that did this.

As for the PR itself: you're right about the Array<Hash> regression; thanks for catching that. The remaining issue Codex is pointing at is in the SDK's Array<Hash> convenience form before it gets flattened into the final Assembly Instructions. For example:

steps: [
  { thumbs: { robot: "/video/thumbs", count: 4 } },
  { thumbs: { robot: "/image/resize", width: 320 } }
]

Those are two different Ruby hashes, so steps.uniq keeps both. But they have the same logical step name/key (thumbs), and the later steps.inject({}) { |h, s| h.update s } flattening silently overwrites the first one. The API ultimately expects steps to be an object keyed by step name, so the SDK should detect duplicate logical names before flattening.

Could we validate duplicates by mapping each array item to its step name/key first, then checking those names for duplicates?

@emrekutlu
Copy link
Copy Markdown
Author

Hi @kvz, I see, that's one of cases I added to the tests but I had some issues running them locally so I was hoping to see them here, I will check again, thanks.

@kvz
Copy link
Copy Markdown
Member

kvz commented May 19, 2026

Okay allowing a run 👌

@emrekutlu emrekutlu reopened this May 19, 2026
@emrekutlu
Copy link
Copy Markdown
Author

I made some changes, hopefully it is in better shape now.

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