Skip to content

Update CHANGELOG with missing entries for version 1.0.2#398

Closed
faheemmughal wants to merge 1 commit intoruby-grape:masterfrom
faheemmughal:patch-1
Closed

Update CHANGELOG with missing entries for version 1.0.2#398
faheemmughal wants to merge 1 commit intoruby-grape:masterfrom
faheemmughal:patch-1

Conversation

@faheemmughal
Copy link
Copy Markdown

Added entries for missing PRs within the version. Especially for a breaking change that is failing 400+ tests for us.

@numbata
Copy link
Copy Markdown
Collaborator

numbata commented Apr 15, 2026

@faheemmughal Thanks for flagging this, really appreciate it.
I’ll add a Danger check to make sure we don’t miss CHANGELOG updates going forward.

Could you share a bit more detail about the “400+ failing tests” you mentioned? Specifically:

  • which versions of grape and grape-entity you’re using
  • whether you have any related gems (e.g. grape-swagger) in the setup

That should help me understand what’s going on 👍

Added entries for missing PRs within the version. Especially for a breaking change that is failing 400+ tests for us.
@faheemmughal
Copy link
Copy Markdown
Author

faheemmughal commented Apr 15, 2026

Thank you for being so responsive.

In our codebase we are using variations of the following,

expose :property, if: ->(model) { model.active? }

expose :storage,
       if: ->(model) { model.storage_method.present? } do |model|
  check_storage(model, :storage_method)
end

Update to version 1.0.2 is causing test failures for us:

  ArgumentError:
       wrong number of arguments (given 2, expected 1)

And forcing us to change the code to,

expose :property, if: ->(model, _) { model.active? }
expose :storage,
       if: ->(model, _) { model.storage_method.present? } do |model, _|
  check_storage(model, :storage_method)
end

I haven't looked too closely at it but it's likely that the change in #389 is the cause.

@numbata
Copy link
Copy Markdown
Collaborator

numbata commented Apr 15, 2026

Thanks for the report and especially for the examples. Sorry for the confusion; this is definitely not the experience we want from the gem.

I’ll prepare a patch release to restore the previous behavior as soon as possible.

numbata added a commit that referenced this pull request Apr 15, 2026
PR #389 changed arity detection to use block.arity.zero? which broke
single-argument lambdas in expose blocks and if: conditions, causing
ArgumentError (given 2, expected 1). Restore parameter count check
for regular blocks while keeping symbol-to-proc detection intact.

Fixes #398
@numbata
Copy link
Copy Markdown
Collaborator

numbata commented Apr 15, 2026

@faheemmughal l The fix is up in #399. Both your original single-argument style and the two-argument workaround will keep working, so no need to roll back any changes you've already made.

Will release 1.0.3 soon.

numbata added a commit that referenced this pull request Apr 15, 2026
#399)

## Summary

Upgrading to 1.0.2 breaks commonly used single-argument lambda patterns
in `expose` blocks and `if:` conditions:

```ruby
expose :property, if: ->(model) { model.active? }

expose :storage, if: ->(model) { model.storage_method.present? } do |model|
  check_storage(model, :storage_method)
end
```

These raise `ArgumentError: wrong number of arguments (given 2, expected
1)` since v1.0.2.

This PR restores support for single-argument lambdas while preserving
the symbol-to-proc (`&:method`) validation introduced in #389. Users who
already applied the two-argument workaround (`->(model, _) { ... }`) are
not affected — both styles work.

Reported in #398.
@numbata numbata self-assigned this Apr 15, 2026
@numbata numbata added the bug label Apr 15, 2026
@numbata
Copy link
Copy Markdown
Collaborator

numbata commented Apr 15, 2026

v1.0.3 is out with the fix from #399. I've incorporated the CHANGELOG updates separately, so closing this PR.

Thanks again for flagging the issue so quickly! And let us know if you run into anything else.

@numbata numbata closed this Apr 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants