apache/pulsar · error · RestException

Function in trigger function has unidentified topic

Error message

Function in trigger function has unidentified topic

What it means

After choosing the input topic (from the request or the function's single inputSpec), triggerFunction verifies the topic actually exists in the function's inputSpecs and that the requested topic matches. A null/empty/unresolvable topic, or one not present in inputSpecs, yields HTTP 400 'Function in trigger function has unidentified topic'.

Source

Thrown at pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/rest/api/ComponentImpl.java:1160

                    .log("Function in trigger function has more than 1 input topics @ / / /");
            throw new RestException(Status.BAD_REQUEST, "Function in trigger function has more than 1 input topics");
        }
        boolean topicFound;
        try {
            functionMetaData.getFunctionDetails().getSource().getInputSpecs(inputTopicToWrite);
            topicFound = true;
        } catch (IllegalArgumentException e) {
            topicFound = false;
        }
        if (functionMetaData.getFunctionDetails().getSource().getInputSpecsCount() == 0
                || !topicFound) {
            log.error().attr("tenant", tenant).attr("namespace", namespace).attr("componentName", functionName)

                    .attr("topic", inputTopicToWrite)

                    .log("Function in trigger function has unidentified topic @ / / /");
            throw new RestException(Status.BAD_REQUEST, "Function in trigger function has unidentified topic");
        }
        try {
            worker().getBrokerAdmin().topics().getSubscriptions(inputTopicToWrite);
        } catch (PulsarAdminException e) {
            log.error().attr("tenant", tenant).attr("namespace", namespace).attr("componentName", functionName)

                    .exception(e).log("Function in trigger function is not ready @ / / /");
            throw new RestException(Status.BAD_REQUEST, "Function in trigger function is not ready");
        }
        String outputTopic = functionMetaData.getFunctionDetails().getSink().getTopic();
        Reader<byte[]> reader = null;
        Producer<byte[]> producer = null;
        try {
            if (!isEmpty(outputTopic)) {
                reader = worker().getClient().newReader()
                        .topic(outputTopic)
                        .startMessageId(MessageId.latest)
                        .readerName(worker().getWorkerConfig().getWorkerId() + "-trigger-"

View on GitHub (pinned to 820761864e)

Solutions

  1. Pass the exact fully-qualified topic name that appears in the function's inputSpecs (persistent://tenant/ns/topic).
  2. Omit the topic parameter so the worker uses the function's single declared input topic.
  3. Compare the function config's inputSpecs keys (GET /functions/{tenant}/{namespace}/{functionName}) with your request topic.
  4. Re-upload/reconfigure the function if its source lost its input specs.

Example fix

// before
curl -X POST --data-binary 'x' '.../functions/public/default/f?topic=src-topic'
// after
curl -X POST --data-binary 'x' '.../functions/public/default/f?topic=persistent://public/default/src-topic'
Defensive patterns

Strategy: validation

Validate before calling

static boolean topicDeclared(FunctionConfig cfg, String requested) {
  return cfg.getSource() != null && cfg.getSource().getInputSpecs() != null
      && cfg.getSource().getInputSpecs().keySet().stream()
         .anyMatch(t -> t.equals(requested) || t.endsWith("/" + requested));
}

Try / catch

if (!topicDeclared(cfg, topic)) throw new IllegalArgumentException("topic not in inputSpecs, expected one of " + cfg.getSource().getInputSpecs().keySet());
triggerFunction(tenant, ns, fn, topic, data, null);

Prevention

When it happens

Trigger: Triggering with a topic query parameter that the function does not declare in its inputSpecs; the function's source has an empty inputSpecs map; the requested topic string doesn't match the fully-resolved inputTopicToWrite.

Common situations: Using the short topic name (e.g. 'src-topic') instead of the fully qualified persistent://tenant/namespace/topic; triggering a function whose source was reconfigured after the trigger script was written.

Related errors


AI-assisted analysis of apache/pulsar@820761864e (2026-09-06). Data as JSON: /api/errors/8ff5b11e29f38301. Report an issue: GitHub.