NASA-AMMOS / NASA-AMMOS/plandev

Merlin Framework: Improve "Failed to generate value mapper" error message

Open
#910 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

feature merlin framework
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.java file for which the @WithMappers annotation(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

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 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.