{"record":{"id":"a6f3c812a4194f80","repo":"pinpoint-apm/pinpoint","slug":"parselong-error-longstring-transactionid-tra","errorCode":null,"errorMessage":"parseLong Error. ${longString} transactionId:${transactionId}","messagePattern":"parseLong Error\\. (.+?) transactionId:(.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"commons-profiler/src/main/java/com/navercorp/pinpoint/common/profiler/util/TransactionIdUtils.java","lineNumber":121,"sourceCode":"        if (transactionSequenceIndex == -1) {\n            // next index may not exist since default value does not have a delimiter after transactionSequence.\n            // may need fixing when id spec changes\n            transactionSequenceIndex = transactionId.length();\n        }\n        final long transactionSequence = parseLong(transactionId, agentStartTimeIndex + 1, transactionSequenceIndex);\n        return TransactionId.of(agentId, agentStartTime, transactionSequence);\n    }\n\n    private static int nextIndex(String transactionId, int fromIndex) {\n        return transactionId.indexOf(TRANSACTION_ID_DELIMITER_CHAR, fromIndex);\n    }\n\n    private static long parseLong(String transactionId, int beginIndex, int endIndex) {\n        final String longString = transactionId.substring(beginIndex, endIndex);\n        try {\n            return Long.parseLong(longString);\n        } catch (NumberFormatException e) {\n            throw new IllegalArgumentException(\"parseLong Error. \" + longString + \" transactionId:\" + transactionId);\n        }\n    }\n}\n","sourceCodeStart":103,"sourceCodeEnd":125,"githubUrl":"https://github.com/pinpoint-apm/pinpoint/blob/744c3d3075e595656abb1ae331ad2c0e4c9eb996/commons-profiler/src/main/java/com/navercorp/pinpoint/common/profiler/util/TransactionIdUtils.java#L103-L125","documentation":"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.","triggerScenarios":"parseTransactionId is given a transactionId whose agentStartTime or transactionSequence segment is non-numeric or empty, e.g. 'agent^abc^1' or 'agent^^1'.","commonSituations":"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.","solutions":["Ensure agentStartTime and transactionSequence segments are decimal longs (e.g. timestamps like 1699999999999)","Rebuild the transactionId from a TransactionId object via TransactionIdUtils.formatString instead of manual string assembly","Inspect the full transactionId in the message to find which segment is non-numeric and where the id came from","Catch IllegalArgumentException around parseTransactionId to handle malformed ids gracefully"],"exampleFix":"// before\nString id = agentId + \"-\" + startTime + \"-\" + seq;\nTransactionId t = TransactionIdUtils.parseTransactionId(id);\n// after\nTransactionId tid = TransactionId.of(agentId, startTime, seq);\nString id = TransactionIdUtils.formatString(tid);","handlingStrategy":"validation","validationCode":"boolean hasNumericSegments(String txId, String delimiter) {\n    String[] parts = (txId == null) ? new String[0] : txId.split(java.util.regex.Pattern.quote(delimiter));\n    for (int i = 1; i < parts.length; i++) {\n        if (!parts[i].matches(\"\\\\d+\")) return false;\n    }\n    return parts.length >= 3;\n}","typeGuard":"boolean hasNumericSegments(String txId, String delimiter) {\n    String[] parts = (txId == null) ? new String[0] : txId.split(java.util.regex.Pattern.quote(delimiter));\n    for (int i = 1; i < parts.length; i++) {\n        if (!parts[i].matches(\"\\\\d+\")) return false;\n    }\n    return parts.length >= 3;\n}","tryCatchPattern":"try {\n    TransactionId id = TransactionIdUtils.parseTransactionId(txId);\n} catch (IllegalArgumentException e) {\n    log.warn(\"non-numeric segment in transactionId: {}\", txId);\n    // reject or re-derive the id from a TransactionId object\n}","preventionTips":["Build ids from TransactionId objects rather than string concatenation","Keep agentStartTime/transactionSequence as decimal longs in any serialized form","Validate id format at ingestion boundaries","Log the full transactionId when parse fails to trace the source of the malformed value"],"tags":["parsing","numberformat","transactionid"],"backgroundTag":"invalid-argument-format","analyzedSha":"744c3d3075e595656abb1ae331ad2c0e4c9eb996","analyzedAt":"2026-09-07T18:48:45.289Z","contentChangedAt":"2026-09-07T18:48:45.289Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}