{"record":{"id":"af4d32e2243d1b5b","repo":"openzipkin/zipkin","slug":"missing-af4d32","errorCode":null,"errorMessage":"Missing :","messagePattern":"Missing :","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"zipkin/src/main/java/zipkin2/Span.java","lineNumber":590,"sourceCode":"        flags |= FLAG_SHARED;\n      } else {\n        flags &= ~FLAG_SHARED;\n      }\n      return this;\n    }\n\n    /** Sets {@link Span#shared} */\n    public Builder shared(@Nullable Boolean shared) {\n      if (shared != null) return shared((boolean) shared);\n      flags &= ~(FLAG_SHARED_SET | FLAG_SHARED);\n      return this;\n    }\n\n    public Span build() {\n      String missing = \"\";\n      if (traceId == null) missing += \" traceId\";\n      if (id == null) missing += \" id\";\n      if (!missing.isEmpty()) throw new IllegalStateException(\"Missing :\" + missing);\n      if (id.equals(parentId)) { // edge case, so don't require a logger field\n        Logger logger = Logger.getLogger(Span.class.getName());\n        if (logger.isLoggable(FINEST)) {\n          logger.fine(format(\"undoing circular dependency: traceId=%s, spanId=%s\", traceId, id));\n        }\n        parentId = null;\n      }\n      // shared is for the server side, unset it if accidentally set on the client side\n      if ((flags & FLAG_SHARED) == FLAG_SHARED && kind == Kind.CLIENT) {\n        Logger logger = Logger.getLogger(Span.class.getName());\n        if (logger.isLoggable(FINEST)) {\n          logger.fine(format(\"removing shared flag on client: traceId=%s, spanId=%s\", traceId, id));\n        }\n        shared(null);\n      }\n      return new Span(this);\n    }\n","sourceCodeStart":572,"sourceCodeEnd":608,"githubUrl":"https://github.com/openzipkin/zipkin/blob/878ce2a1fad54ca941d17fdcf2e1d924b148eb1f/zipkin/src/main/java/zipkin2/Span.java#L572-L608","documentation":"Span.Builder.build() throws IllegalStateException('Missing : traceId') / ('Missing : id') when the span is built without the two mandatory fields. Unlike bad-format errors thrown at setter time, this is a completeness check at build time: traceId and id must both have been set (via any overload). The message concatenates every missing field, e.g. 'Missing : traceId id'.","triggerScenarios":"Building a span after setting only id (trace ID never set), only traceId, or neither — often when the code builds first and conditionally sets IDs afterwards, or when ID-setting code is skipped on an error path that still reaches build().","commonSituations":"Shared span-building helper where some callers pass a nullable trace context and the helper skips the setter on null; async/reporter code that rebuilds partial spans for error reporting; refactoring that moved traceId() out of a base method.","solutions":["Ensure every code path sets both .traceId(...) and .id(...) before build(); check the conditional branches that skip them.","If a trace context may be absent, branch explicitly: either start a new trace (generate both IDs) or skip reporting — never build a partial span.","Move build() after all setters in the method so no early return path can bypass ID assignment."],"exampleFix":"// before\nSpan.Builder b = Span.newBuilder().id(spanId);\nif (traceContext != null) b.traceId(traceContext.traceIdString());\nreturn b.build(); // ISE when traceContext == null\n\n// after\nSpan.Builder b = Span.newBuilder().id(spanId);\nif (traceContext == null) return null; // or generate a new trace id\nreturn b.traceId(traceContext.traceIdString()).build();","handlingStrategy":"validation","validationCode":"// before build(): ensure mandatory fields\nif (traceId == null || spanId == null) {\n  throw new IllegalStateException(\"refusing to build incomplete span\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  return builder.build();\n} catch (IllegalStateException e) {\n  if (e.getMessage().startsWith(\"Missing :\")) { /* log + drop malformed span */ }\n  else throw e;\n}","preventionTips":["Keep all mandatory setters on one unconditional code path before build().","In collectors, catch 'Missing :' ISE to quarantine malformed inbound spans instead of crashing the consumer."],"tags":["zipkin","span","builder","validation","illegal-state"],"backgroundTag":null,"analyzedSha":"878ce2a1fad54ca941d17fdcf2e1d924b148eb1f","analyzedAt":"2026-08-14T15:17:09.895Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}