Show an error if an argument defined in `define_calculation` is not accepted in the calculation itself
Nobody has claimed this yet.
- Dominant language
- Elixir
- Stars
- 2.5k
- Forks
- 426
- Avg merge
- 23h 26m
- Merged PRs (30d)
- 46
Description
Is your feature request related to a problem? Please describe.
I just faced a bug where my define_calculation definition included an argument that wasn't listed in the calculation itself, i.e.
code_interface do
define_calculation :display_product_variant, args: [:_record, :product_variant_id]
end
calculations do
calculate :display_product_variant,
:struct,
Calculations.DisplayProductVariant,
constraints: [instance_of: Shopifex.Products.ProductVariant]
end
and I didn't figure out why until @sevenseacat pointed it out.
Describe the solution you'd like
It'd be helpful if, in cases like these, an error was thrown saying that the calculation code interface is attempting to define an argument not accepted by the calculation.
Additional context
@zachdaniel on Discord:
I think whats "complicated" about it is that its using that as a ref
and we don't know what references a calculations use
i.e an attribute reference in an expression calculation
but...your calculation doesn't define an expression, so we actually could have done that
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the define_calculation code interface and the calculations definition shown in the issue, then inspect how calculation arguments and references are validated. Determine whether the calculation can identify accepted arguments across the mentioned calculation forms, and treat completion as producing a clear error for an unsupported code-interface argument without breaking valid references.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- elixir
- Domain
- backend, backend-api-design
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100