{"record":{"id":"7370bcb459c218b3","repo":"microsoft/aspire","slug":"claimedsectionsproperty-must-contain-a-json-array-of-non","errorCode":null,"errorMessage":"'{ClaimedSectionsProperty}' must contain a JSON array of non-empty strings.","messagePattern":"'(.+?)' must contain a JSON array of non-empty strings\\.","errorType":"exception","errorClass":"InvalidDataException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting/Pipelines/Internal/FileDeploymentStateManager.cs","lineNumber":779,"sourceCode":"        var currentState = migrationState[CurrentStateProperty] switch\n        {\n            null => null,\n            JsonValue stateValue => JsonNode.Parse(stateValue.GetValue<string>())?.AsObject()\n                ?? throw new InvalidDataException($\"'{CurrentStateProperty}' must contain a JSON object.\"),\n            _ => throw new InvalidDataException($\"'{CurrentStateProperty}' must be a JSON string.\")\n        };\n\n        return new(legacyFallbackDisabled, legacyStateSnapshot, claimedSectionNames, currentState);\n    }\n\n    private static string[] ParseClaimedSectionNames(JsonValue claimedSectionsValue)\n    {\n        var claimedSectionNames = JsonSerializer.Deserialize<string?[]>(\n            claimedSectionsValue.GetValue<string>());\n        if (claimedSectionNames is null ||\n            claimedSectionNames.Any(string.IsNullOrWhiteSpace))\n        {\n            throw new InvalidDataException(\n                $\"'{ClaimedSectionsProperty}' must contain a JSON array of non-empty strings.\");\n        }\n\n        return [.. claimedSectionNames.Select(static sectionName => sectionName!)];\n    }\n\n    private Task SaveMigrationStateAsync(string canonicalStatePath, CancellationToken cancellationToken) =>\n        SaveMigrationStateAsync(\n            canonicalStatePath,\n            _currentState,\n            _legacyStateSnapshot,\n            _claimedSectionNames,\n            _legacyFallbackDisabled,\n            cancellationToken);\n\n    private static Task SaveMigrationStateAsync(\n        string canonicalStatePath,\n        JsonObject currentState,","sourceCodeStart":761,"sourceCodeEnd":797,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting/Pipelines/Internal/FileDeploymentStateManager.cs#L761-L797","documentation":"Aspire's FileDeploymentStateManager persists per-deployment state (including which pipeline sections have been claimed) in a state file. When loading, it reads the ClaimedSectionsProperty value and deserializes it as a JSON array of strings; if the stored value is null, not valid JSON for a string array, or contains null/whitespace entries, the state file is considered corrupt and this InvalidDataException is thrown to fail fast rather than silently re-run or skip claimed deployment sections.","triggerScenarios":"Calling the section-claiming load path when the saved state file's ClaimedSectionsProperty contains: a JSON null, a non-array JSON value (e.g. a plain string or object), an array containing null or whitespace-only strings, or corrupt/truncated JSON written by a previous crashed run.","commonSituations":"A deployment state file edited by hand, a state file produced by an older or newer Aspire version with a different schema, a partially-written state file after a crashed or killed deployment, or a custom state manager writing the property in the wrong format.","solutions":["Delete or rename the corrupted deployment state file (e.g. under the deployment state directory) and re-run the deployment so a fresh state is written.","Verify the code writing ClaimedSectionsProperty serializes a List<string> of non-empty names via JsonSerializer, not a raw joined string or null.","If a custom IResource or state provider supplies the value, ensure GetValue returns valid JSON text like [\"sectionA\",\"sectionB\"].","Upgrade/downgrade so the writing and reading Aspire versions agree on the state-file schema."],"exampleFix":"// before: writes an invalid claimed-sections value\nstate[\"ClaimedSections\"] = string.Join(\",\", sections);\n// after\nstate[\"ClaimedSections\"] = JsonSerializer.Serialize(sections);","handlingStrategy":"validation","validationCode":"if (JsonSerializer.Deserialize<string?[]>(claimedValue) is not { } names || names.Any(string.IsNullOrWhiteSpace))\n    throw new InvalidDataException(\"ClaimedSections state is corrupt; delete the state file and retry.\");","typeGuard":"bool IsValidClaimedSections(string?[]? names) => names is not null && !names.Any(string.IsNullOrWhiteSpace);","tryCatchPattern":"try { LoadClaimedSections(state); } catch (InvalidDataException ex) { logger.LogWarning(ex, \"Corrupt deployment state; resetting claimed sections.\"); state.Remove(ClaimedSectionsProperty); }","preventionTips":["Only write ClaimedSectionsProperty via JsonSerializer.Serialize on a non-empty-string collection","Never hand-edit deployment state files","Bump the state-file schema/version key when changing the format","Treat parse failures as a reset signal, not a crash, in tooling that reads state files"],"tags":["state-file","json-validation","deployment"],"backgroundTag":"schema-validation-failed","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}