NASA-AMMOS / NASA-AMMOS/plandev
Merlin Framework: Improve "Failed to generate value mapper" error message
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 128
- Forks
- 33
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 12
Description
Checked for duplicates
Yes - I've already checked
Alternatives considered
Yes - and alternatives don't suffice
Related problems
When a directive type declares a field whose type does not have a value mapper, the annotation processor fails with this error at build time:
> Task :eurc:compileJava
/<snip>.java:55: error: Failed to generate value mapper for parameter
public List<EquatorialCoordinate> targetList = List.of(EquatorialCoordinate.fromRadians(0, 0));
This does not adequately explain what the root problem is, or how to address it. In this case, the value mapper for EquatorialCoordinate is not registered under a @WithMappers annotation in this context. EquatorialCoordinate happens to be defined in a separate library, and similar uses within that library do work as expected, since its ValueMapper is known in that context. This makes it even less obvious at first glance what the problem is, since it appears to work sometimes but not others.
Describe the feature request
The given error message should be augmented to include the following information:
- The type(s, if multiple) for which a value mapper could not be found
- The
package-info.javafile for which the@WithMappersannotation(s) are expected to see a static factory for the given type's value mapper.
This will provide a much more direct path to a solution for a user who encounters this kind of problem for the first time (or in an unexpected context).
(For full disclosure, I'm reporting this issue on behalf of a user who raised a question revolving around this error in Slack.)
Strawman proposal:
/<snip>.java:55: error: Failed to generate value mapper for parameter -- no applicable ValueMapper factory for EquatorialCoordinate
public List<EquatorialCoordinate> targetList = List.of(EquatorialCoordinate.fromRadians(0, 0));
/<snip>/package-info:.java:1: info: Has a value mapper for `EquatorialCoordinate` been registered at `/<snip/package-info:.java`?
(Repeat this pair of messages for every encountered type lacking an accessible ValueMapper.)
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 locating the Merlin annotation processor code that emits “Failed to generate value mapper for parameter” and the related diagnostic tests, if present. Trace how the unavailable type and relevant package-info.java context are known. Done means diagnostics identify each missing type and the package-info.java location where its ValueMapper factory is expected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- build-system, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100