Skip to content

Fix/code interface validation hint#2697

Merged
zachdaniel merged 3 commits into
ash-project:mainfrom
febarnett3:fix/code-interface-validation-hint
May 12, 2026
Merged

Fix/code interface validation hint#2697
zachdaniel merged 3 commits into
ash-project:mainfrom
febarnett3:fix/code-interface-validation-hint

Conversation

@febarnett3
Copy link
Copy Markdown
Contributor

Contributor checklist

Leave anything that you believe does not apply unchecked.

  • I accept the AI Policy, or AI was not used in the creation of this PR.
  • Bug fixes include regression tests
  • Chores
  • Documentation changes
  • Features include unit/acceptance tests
  • Refactoring
  • Update dependencies

Summary

Resolves #992

Improves code interface validation errors when action params are accidentally passed as a keyword list instead of a params map.

Example of the incorrect call shape:

MyApi.create_user(first_name: "Fred")

instead of:

MyApi.create_user(%{first_name: "Fred"})

Previously, Ash raised an unknown options error for :first_name even when it was a valid action input. This PR adds a targeted hint explaining the likely mistake and shows the expected call shape.

Behavior

When unknown options are detected, Ash now checks whether those keys are valid action inputs.

If they are, the validation error includes a helpful hint with the proper function usage. Non-input unknown options continue behaving exactly as before.

Tests

Added regression coverage for:

  • create interfaces with keyword-list params
  • bang interfaces showing the correct function name
  • unknown non-input options not receiving hints
  • update interfaces showing the record argument in examples

Comment thread lib/ash/code_interface.ex Outdated
@zachdaniel
Copy link
Copy Markdown
Contributor

This looks great! Just had one comment and then we can merge 😄

Co-authored-by: Zach Daniel <zachary.s.daniel@gmail.com>
@febarnett3
Copy link
Copy Markdown
Contributor Author

Thanks for the review! I committed your suggested edit to the branch.

@zachdaniel zachdaniel merged commit 5790310 into ash-project:main May 12, 2026
40 of 43 checks passed
@zachdaniel
Copy link
Copy Markdown
Contributor

🚀 Thank you for your contribution! 🚀

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.

Calling a code interface create with keyword as input instead of a map gives a non-helpful failure message.

2 participants