pinpoint-apm/pinpoint · error · IllegalArgumentException

parseLong Error. transactionId

Error message

parseLong Error. ${longString} transactionId:${transactionId}

What it means

parseLong extracts a substring of the transactionId that should be a numeric agentStartTime or transactionSequence and calls Long.parseLong. If the substring is not a valid long (non-digits, empty, out of range), the NumberFormatException is rethrown as an IllegalArgumentException with the offending segment and the full transactionId.

Solutions

  1. Ensure agentStartTime and transactionSequence segments are decimal longs (e.g. timestamps like 1699999999999)
  2. Rebuild the transactionId from a TransactionId object via TransactionIdUtils.formatString instead of manual string assembly
  3. Inspect the full transactionId in the message to find which segment is non-numeric and where the id came from
  4. Catch IllegalArgumentException around parseTransactionId to handle malformed ids gracefully

Example fix

// before
String id = agentId + "-" + startTime + "-" + seq;
TransactionId t = TransactionIdUtils.parseTransactionId(id);
// after
TransactionId tid = TransactionId.of(agentId, startTime, seq);
String id = TransactionIdUtils.formatString(tid);
Defensive patterns

Strategy: validation

Validate before calling

boolean hasNumericSegments(String txId, String delimiter) {
    String[] parts = (txId == null) ? new String[0] : txId.split(java.util.regex.Pattern.quote(delimiter));
    for (int i = 1; i < parts.length; i++) {
        if (!parts[i].matches("\\d+")) return false;
    }
    return parts.length >= 3;
}

Type guard

boolean hasNumericSegments(String txId, String delimiter) {
    String[] parts = (txId == null) ? new String[0] : txId.split(java.util.regex.Pattern.quote(delimiter));
    for (int i = 1; i < parts.length; i++) {
        if (!parts[i].matches("\\d+")) return false;
    }
    return parts.length >= 3;
}

Try / catch

try {
    TransactionId id = TransactionIdUtils.parseTransactionId(txId);
} catch (IllegalArgumentException e) {
    log.warn("non-numeric segment in transactionId: {}", txId);
    // reject or re-derive the id from a TransactionId object
}

Prevention

When it happens

Trigger: parseTransactionId is given a transactionId whose agentStartTime or transactionSequence segment is non-numeric or empty, e.g. 'agent^abc^1' or 'agent^^1'.

Common situations: Corrupted or manually edited transactionId strings; ids built with a wrong field order; ids where a numeric field was replaced with a hex or UUID value; truncation that leaves a partial number.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


AI-assisted analysis of pinpoint-apm/pinpoint@744c3d3075 (2026-09-07). Data as JSON: /api/errors/a6f3c812a4194f80. Report an issue: GitHub.

Appendix: source

Thrown at commons-profiler/src/main/java/com/navercorp/pinpoint/common/profiler/util/TransactionIdUtils.java:121

        if (transactionSequenceIndex == -1) {
            // next index may not exist since default value does not have a delimiter after transactionSequence.
            // may need fixing when id spec changes
            transactionSequenceIndex = transactionId.length();
        }
        final long transactionSequence = parseLong(transactionId, agentStartTimeIndex + 1, transactionSequenceIndex);
        return TransactionId.of(agentId, agentStartTime, transactionSequence);
    }

    private static int nextIndex(String transactionId, int fromIndex) {
        return transactionId.indexOf(TRANSACTION_ID_DELIMITER_CHAR, fromIndex);
    }

    private static long parseLong(String transactionId, int beginIndex, int endIndex) {
        final String longString = transactionId.substring(beginIndex, endIndex);
        try {
            return Long.parseLong(longString);
        } catch (NumberFormatException e) {
            throw new IllegalArgumentException("parseLong Error. " + longString + " transactionId:" + transactionId);
        }
    }
}

View on GitHub (pinned to 744c3d3075)