luckyframework / luckyframework/avram

Confusing error when calling the wrong preload method

Open
#613 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

improve error experience
Dominant language
Crystal
Stars
183
Forks
67
PR merge metrics
No merged PRs in 30d

Description

I'm getting this error, but haven't figured out why yet.

A `User` `has_one stream_approval : StreamApproval`

```
web |
web | 141 | UserSerializer.new(UserQuery.new.preload_stream_approval(current_user))
web | ^----------------------
web | Error: no overload matches 'UserQuery#preload_stream_approval' with type User
web |
web | Overloads are:
web | - User::BaseQuery#preload_stream_approval(preload_query : StreamApproval::BaseQuery)
web | - User::BaseQuery#preload_stream_approval()
web |
web | ---
```

The strange thing is that it only shows these two overloads, but there's 8 different versions of this method.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the UserQuery.new.preload_stream_approval(current_user) call shown in the report and inspect how the has_one association generates its preload_stream_approval overloads. Reproduce the compiler error and compare the generated overload list with the reported eight versions. Done means the incorrect or incomplete error output is explained and covered by a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
crystal
Domain
database
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.