{"record":{"id":"501f807f11f9e619","repo":"rustfs/rustfs","slug":"jsonparsingerror","errorCode":"JSONParsingError","errorMessage":"An error occurred while parsing the JSON file. Check the file and try again.","messagePattern":"An error occurred while parsing the JSON file\\. Check the file and try again\\.","errorType":"http","errorClass":"SelectError","httpStatus":400,"severity":"error","filePath":"crates/s3select-api/src/lib.rs","lineNumber":91,"sourceCode":"}\n\n#[derive(Clone, Debug, Error, PartialEq, Eq)]\npub enum SelectError {\n    #[error(\"The file is not in a supported compression format. Only GZIP and BZIP2 are supported.\")]\n    InvalidCompressionFormat,\n\n    #[error(\"The data source type is not valid. Only CSV, JSON, and Parquet are supported.\")]\n    InvalidDataSource,\n\n    #[error(\n        \"Object decompression failed. Check that the object is properly compressed using the format specified in the request.\"\n    )]\n    TruncatedInput,\n\n    #[error(\"An error occurred while parsing the CSV file. Check the file and try again.\")]\n    CsvParsingError,\n\n    #[error(\"An error occurred while parsing the JSON file. Check the file and try again.\")]\n    JsonParsingError,\n\n    #[error(\"An error occurred while parsing the Parquet file. Check the file and try again.\")]\n    ParquetParsingError,\n\n    #[error(\"{message}\")]\n    ParseSelectFailure { message: String },\n\n    #[error(\"The SQL expression is invalid.\")]\n    InvalidQuery,\n\n    #[error(\"The SQL expression contains a data type that is not valid.\")]\n    InvalidDataType,\n\n    #[error(\"An incorrect argument type was specified in a function call in the SQL expression.\")]\n    IncorrectSqlFunctionArgumentType,\n\n    #[error(\"The data source path in the SQL expression is not supported.\")]","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/rustfs/rustfs/blob/35af688cd9d41b4346fbe27dcf7250ba72046c1f/crates/s3select-api/src/lib.rs#L73-L109","documentation":"SelectError::JsonParsingError is the classification of ArrowError::JsonError (crates/s3select-api/src/lib.rs:228) and of the select object store's JSON line-scan failure (crates/s3select-api/src/object_store.rs:1191). The JSON reader could not parse the object's lines or documents: syntax errors or type-inconsistent records.","triggerScenarios":"SelectObjectContent with JSON input serialization on a file containing malformed lines (truncated records, trailing commas, single quotes), mixed types for the same key across lines, or invalid UTF-8; JSON Type (DOCUMENT vs LINES) not matching the file layout.","commonSituations":"JSON Lines files with one truncated line from a partial append; pretty-printed multi-line JSON fed to a line-oriented reader; heterogeneous event logs where a field changes type between records.","solutions":["Validate the object client-side before selecting (jq for DOCUMENT; per-line jq -c or python json.loads for LINES)","Make the JSON Type in the request match the actual layout (DOCUMENT for a single pretty-printed value, LINES for newline-delimited records)","Keep types consistent per key across records, or normalize dirty values before upload","Drop or fix malformed lines and re-upload the object"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Pre-validate JSON Lines objects line by line before selecting.\nfor (i, line) in head_bytes.lines().enumerate() {\n    let line = line?;\n    if line.trim().is_empty() { continue; }\n    serde_json::from_str::<serde_json::Value>(line)\n        .map_err(|e| err(format!(\"line {}: {e}\", i + 1)))?;\n}","typeGuard":null,"tryCatchPattern":"match select_object_content(req).await {\n    Ok(resp) => { /* records */ }\n    Err(e) if matches!(e.select_error(), SelectError::JsonParsingError) => {\n        // Report the malformed-object condition; do not retry the same bytes.\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Emit one JSON value per line for LINES inputs; validate with jq in CI","Keep per-key types stable across records"],"tags":["s3-select","json","parsing","arrow"],"backgroundTag":"json-parse-error","analyzedSha":"35af688cd9d41b4346fbe27dcf7250ba72046c1f","analyzedAt":"2026-08-20T21:57:04.799Z","contentChangedAt":"2026-08-20T21:57:04.799Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}