Skip to content

FLX-1001

cannot find a matching constructor for com.example.PurchaseOrderRaiser — no constructor accepts the mapped fields [scorecard]

Severity ERROR
Category GRAPH_MODEL
Element NODE

The rule

Constructor parameters must correspond to mapped fields, in order.

Why the compiler says this

Fluxtion reproduces each node in generated source by calling a constructor. By default it constructor-maps every final, non-transient instance field that is not @FluxtionIgnore. @ConstructorArg on a field, or @AssignToField on a constructor parameter naming it, is an explicit escape hatch that opts that field into constructor mapping regardless of finality. It then looks for a constructor whose parameters match the mapped fields by type and order. No constructor accepts the listed mapped fields. Fields classified as graph references must be passed in; a field that could not be classified is listed without guessing what it represents.

How to fix it

Add a constructor to PurchaseOrderRaiser taking [scorecard] in that order, or annotate the parameters with @AssignToField when two share a type. A constructor is not the only route: a field not explicitly opted into constructor mapping can be made NON-FINAL and wired through its JavaBean setter. Remove any @ConstructorArg/ @AssignToField opt-in for that field when choosing the setter route.

Example

Both examples are compiled and put through a real Fluxtion.compile on every build, so the first is guaranteed to produce this diagnostic and the second to build cleanly. Note that the failing example is valid Java — javac is happy, and Fluxtion refuses it for its own reasons.

The code that causes it

package com.telamin.fluxtion.builder.diagnostic.examples;

import com.telamin.fluxtion.builder.generation.config.EventProcessorConfig;
import com.telamin.fluxtion.runtime.annotations.OnEventHandler;
import com.telamin.fluxtion.runtime.annotations.OnTrigger;

/** FLX-1001 — a final graph reference no constructor accepts. */
public class Flx1001Failing {

    public static class PriceSource {
        @OnEventHandler
        public boolean onPrice(String event) {
            return true;
        }
    }

    public static class OrderRouter {
        // FINAL, so Fluxtion can only supply it through a constructor…
        private final PriceSource prices;

        // …but the only constructor also wants a String the graph cannot provide.
        public OrderRouter(PriceSource prices, String venue) {
            this.prices = prices;
        }

        @OnTrigger
        public boolean onPrice() {
            return true;
        }
    }

    public static void graph(EventProcessorConfig config) {
        PriceSource prices = new PriceSource();
        config.addNode(prices, "prices");
        config.addNode(new OrderRouter(prices, "LSE"), "orderRouter");
    }
}

The code that fixes it

package com.telamin.fluxtion.builder.diagnostic.examples;

import com.telamin.fluxtion.builder.generation.config.EventProcessorConfig;
import com.telamin.fluxtion.runtime.annotations.OnEventHandler;
import com.telamin.fluxtion.runtime.annotations.OnTrigger;
import com.telamin.fluxtion.runtime.annotations.builder.FluxtionIgnore;

/** FLX-1001 fixed — the constructor accepts exactly what the graph supplies. */
public class Flx1001Fixed {

    public static class PriceSource {
        @OnEventHandler
        public boolean onPrice(String event) {
            return true;
        }
    }

    public static class OrderRouter {
        private final PriceSource prices;

        // Not a graph reference: excluded, so it is not expected from a constructor.
        @FluxtionIgnore
        private final String venue = "LSE";

        // Takes only what the graph can give it.
        public OrderRouter(PriceSource prices) {
            this.prices = prices;
        }

        @OnTrigger
        public boolean onPrice() {
            return true;
        }
    }

    public static void graph(EventProcessorConfig config) {
        PriceSource prices = new PriceSource();
        config.addNode(prices, "prices");
        config.addNode(new OrderRouter(prices), "orderRouter");
    }
}

Which builds raise it

Source-generating (AOT) builds only. An interpreted or in-process build runs from the live node instances and never renders them as Java source, so it does not raise this. A graph developed interpreted can therefore meet this rejection for the first time at AOT build — that is by design, not a regression.

Reading it programmatically

This diagnostic is also written to the machine-readable report — the opt-in sidecar (-Dfluxtion.diagnostics.sidecar=true), or FluxtionDiagnostics.capture(...) for a caller that wants the objects:

{
  "code": "FLX-1001",
  "severity": "ERROR",
  "category": "GRAPH_MODEL",
  "element": { "kind": "NODE",  }
}

Select findings by severity, never by position: a failing build's report also contains any warnings it found, and diagnostics[0] is not the cause of the failure.


This page is generated from the compiler itself, so the wording above is exactly what a build emits. Do not edit it by hand — it is overwritten whenever the diagnostics are regenerated.