{"record":{"id":"f24943d6dd8c6ae0","repo":"elsa-workflows/elsa-core","slug":"unexpected-end-of-json-while-reading-secret-metadata","errorCode":null,"errorMessage":"Unexpected end of JSON while reading secret metadata.","messagePattern":"Unexpected end of JSON while reading secret metadata\\.","errorType":"exception","errorClass":"JsonException","httpStatus":null,"severity":"error","filePath":"src/modules/Elsa.Secrets/Models/OrdinalIgnoreCaseDictionaryConverter.cs","lineNumber":27,"sourceCode":"    {\n        if (reader.TokenType == JsonTokenType.Null)\n            return new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);\n\n        if (reader.TokenType != JsonTokenType.StartObject)\n            throw new JsonException(\"Expected an object of string metadata values.\");\n\n        var values = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);\n        while (reader.Read())\n        {\n            if (reader.TokenType == JsonTokenType.EndObject)\n                return values;\n\n            if (reader.TokenType != JsonTokenType.PropertyName)\n                throw new JsonException(\"Expected a metadata property name.\");\n\n            var key = reader.GetString()!;\n            if (!reader.Read())\n                throw new JsonException(\"Unexpected end of JSON while reading secret metadata.\");\n\n            if (reader.TokenType == JsonTokenType.Null)\n                continue;\n\n            if (reader.TokenType != JsonTokenType.String)\n                throw new JsonException(\"Expected a string metadata value.\");\n\n            var value = reader.GetString();\n            if (value != null)\n                values[key] = value;\n        }\n\n        throw new JsonException(\"Unexpected end of JSON while reading secret metadata.\");\n    }\n\n    public override void Write(Utf8JsonWriter writer, IDictionary<string, string> value, JsonSerializerOptions options)\n    {\n        writer.WriteStartObject();","sourceCodeStart":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/elsa-workflows/elsa-core/blob/fe9217bdfa0e27f0e09e45006eb6898f616e513d/src/modules/Elsa.Secrets/Models/OrdinalIgnoreCaseDictionaryConverter.cs#L9-L45","documentation":"After reading a metadata property name, the converter reads the next token for the value; if the reader is exhausted (no more tokens) the JSON ended mid-property and this JsonException is thrown. Like error 306, it signals truncated/incomplete JSON, here inside the secret metadata object.","triggerScenarios":"Deserializing a Secret whose JSON ends right after a metadata property name, e.g. \"metadata\": { \"env\": — from a truncated write, cut-off response, or manually clipped document.","commonSituations":"Storage truncation (column size limits), interrupted writes/crashes mid-save, or manually pasted JSON missing its tail.","solutions":["Repair or re-save the secret document so the metadata object is complete.","Restore the document from backup if the value is unrecoverable.","Check storage column sizes/encoding for truncation causes.","Parse-validate JSON completeness before persisting or forwarding it."],"exampleFix":"// before (truncated)\n{ \"metadata\": { \"env\":\n\n// after\n{ \"metadata\": { \"env\": \"prod\" } }","handlingStrategy":"validation","validationCode":"try { using var _ = JsonDocument.Parse(json); } catch (JsonException) { throw new InvalidOperationException(\"Secret JSON is truncated or malformed.\"); }","typeGuard":null,"tryCatchPattern":"try { var secret = JsonSerializer.Deserialize<Secret>(json, options); }\ncatch (JsonException ex) when (ex.Message.Contains(\"Unexpected end of JSON\")) { /* reload from backup or re-create the secret */ }","preventionTips":["Parse-validate JSON before storing it in custom stores.","Ensure storage columns can hold the full payload.","Detect and retry failed/partial writes during saves."],"tags":["json","truncation","data-corruption","metadata"],"backgroundTag":"json-parse-error","analyzedSha":"fe9217bdfa0e27f0e09e45006eb6898f616e513d","analyzedAt":"2026-09-13T20:32:34.702Z","contentChangedAt":"2026-09-13T20:32:34.702Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}