{"record":{"id":"e18e5af589ac3d1b","repo":"apache/druid","slug":"failed-to-sample-data-s","errorCode":null,"errorMessage":"Failed to sample data: %s","messagePattern":"Failed to sample data: (.+?)","errorType":"exception","errorClass":"SamplerException","httpStatus":null,"severity":"error","filePath":"indexing-service/src/main/java/org/apache/druid/indexing/overlord/sampler/InputSourceSampler.java","lineNumber":290,"sourceCode":"            );\n          }\n        }\n\n        return new SamplerResponse(\n            numRowsRead,\n            numRowsIndexed,\n            logicalDimensionSchemas,\n            physicalDimensionSchemas,\n            signatureBuilder.build(),\n            responseRows.stream()\n                        .filter(Objects::nonNull)\n                        .filter(x -> x.getParsed() != null || x.isUnparseable() != null)\n                        .collect(Collectors.toList())\n        );\n      }\n    }\n    catch (Exception e) {\n      throw new SamplerException(e, \"Failed to sample data: %s\", e.getMessage());\n    }\n  }\n\n  private InputSourceReader buildReader(\n      SamplerConfig samplerConfig,\n      DataSchema dataSchema,\n      InputSource inputSource,\n      @Nullable InputFormat inputFormat,\n      File tempDir\n  )\n  {\n    final InputRowSchema inputRowSchema = InputRowSchemas.fromDataSchema(dataSchema);\n\n    InputSourceReader reader = inputSource.reader(inputRowSchema, inputFormat, tempDir);\n\n    if (samplerConfig.getTimeoutMs() > 0) {\n      reader = new TimedShutoffInputSourceReader(reader, DateTimes.nowUtc().plusMillis(samplerConfig.getTimeoutMs()));\n    }","sourceCodeStart":272,"sourceCodeEnd":308,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/indexing-service/src/main/java/org/apache/druid/indexing/overlord/sampler/InputSourceSampler.java#L272-L308","documentation":"InputSourceSampler wraps any exception raised while reading and parsing sampled input data into a SamplerException with this message. Sampling runs a short-lived reader over the input source (e.g. for the data loader or ingestion spec preview); failures there — bad input source config, unreadable storage, malformed records — surface through this catch-all. The original exception is attached as the cause and its message is embedded in the entity.","triggerScenarios":"POST /druid/indexer/v1/sampler (or via the web-console data loader preview) where opening/reading the InputSource throws: wrong S3/GCS/local path or credentials, unsupported input format, parser/schema mismatch, or the sampler's flush threshold is exceeded.","commonSituations":"Previewing a Kafka/Kinesis topic with misconfigured bootstrap servers or no read permission; sampling a file whose format does not match the parseSpec; sampling data whose rows fail every parse attempt plus an internal reader bug; timeout reading cold storage.","solutions":["Read e.getMessage() / the exception cause in the response — it names the real failure","Fix the inputSource config (paths, URIs, connection settings, credentials) and retry the sample","Align the parser/inputFormat with the actual data format before sampling","Reduce samplerConfig maxRows/targetPartitionSize if huge rows trigger the flush threshold error"],"exampleFix":"// before\n{\"type\":\"s3\",\"uris\":[\"s3://bucket/wik.json\"]}  // no credentials configured\n// after\n{\"type\":\"s3\",\"properties\":{\"accessKeyId\":\"...\",\"secretAccessKey\":\"...\"},\"uris\":[\"s3://bucket/wik.json\"]}","handlingStrategy":"try-catch","validationCode":"// sanity-check the input source config before sampling\nif (!spec.inputSource || !spec.parser && !spec.inputFormat) throw new Error('inputSource and inputFormat required');","typeGuard":"function isSampleable(spec) { return spec != null && spec.inputSource != null && spec.inputSource.type != null && (spec.inputFormat != null || spec.parser != null); }","tryCatchPattern":"try { await sample(spec); } catch (e) { if (/Failed to sample data/.test(e.message)) { inspectCause(e); fixInputSourceConfig(); } else throw e; }","preventionTips":["Validate inputSource paths/credentials before opening the sampler","Match the parse spec to real data format using a small local file first","Keep samplerConfig row limits modest during iterative spec development"],"tags":["ingestion","sampling","http","druid-overlord"],"backgroundTag":"api-request-failed","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}