Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error messages depends on previous requests #2460

Closed
seriousdev-gh opened this issue Jun 25, 2024 · 2 comments · Fixed by #2463
Closed

Error messages depends on previous requests #2460

seriousdev-gh opened this issue Jun 25, 2024 · 2 comments · Fixed by #2463

Comments

@seriousdev-gh
Copy link

Current Behavior: Error messages contain indices of elements from the previous request.

Expected Behavior: Error messages should be idempotent; for two identical requests, I expect the same error message.

Parameters:

params do
  requires :items, type: Array do
    requires :item, type: Hash do
      requires :name, type: String
    end
  end
end

Sequence of Requests:

Request 1: {}
Response: 'items is missing, items[item][name] is missing'

Request 2: {"items":[{"item":{"name":"foo"}},{"item":{"name":"foo"}},{}]}
Response: 'items[2][item] is missing, items[2][item][name] is missing'

Request 3: {}
Response: 'items is missing, items[2][item][name] is missing'

The response to the last request should be the same as the response to the first request.

This issue is reproducible in version 1.7.1 and in the main branch.

@ericproulx
Copy link
Contributor

I could reproduce in within 1.5.3. That's an old one. Thank you for pointing out and the specs

@ericproulx
Copy link
Contributor

@seriousdev-gh found a way to fix it

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

Successfully merging a pull request may close this issue.

2 participants