{"record":{"id":"6df62062e0d91e45","repo":"microsoft/semantic-kernel","slug":"filepath-for-process-processstateinfo-name-does","errorCode":null,"errorMessage":"Filepath for process {processStateInfo.Name} does not have .json extension","messagePattern":"Filepath for process (.+?) does not have \\.json extension","errorType":"exception","errorClass":"KernelException","httpStatus":null,"severity":"warning","filePath":"dotnet/samples/GettingStartedWithProcesses/Utilities/ProcessStateMetadataUtilities.cs","lineNumber":63,"sourceCode":"\n        return filepath;\n    }\n\n    /// <summary>\n    /// Function that stores the definition of the SK Process State`.<br/>\n    /// </summary>\n    /// <param name=\"processStateInfo\">Process State to be stored</param>\n    /// <param name=\"fullFilepath\">Filepath to store definition of process in json format</param>\n    private static void StoreProcessStateLocally(KernelProcessStateMetadata processStateInfo, string fullFilepath)\n    {\n        if (!(Path.GetDirectoryName(fullFilepath) is string directory && Directory.Exists(directory)))\n        {\n            throw new KernelException($\"Directory for path '{fullFilepath}' does not exist, could not save process {processStateInfo.Name}\");\n        }\n\n        if (!(Path.GetExtension(fullFilepath) is string extension && !string.IsNullOrEmpty(extension) && extension == \".json\"))\n        {\n            throw new KernelException($\"Filepath for process {processStateInfo.Name} does not have .json extension\");\n        }\n\n        string content = JsonSerializer.Serialize(processStateInfo, s_jsonOptions);\n        Console.WriteLine($\"Process State: \\n{content}\");\n        Console.WriteLine($\"Saving Process State Locally: \\n{Path.GetFullPath(fullFilepath)}\");\n        File.WriteAllText(fullFilepath, content);\n    }\n}\n","sourceCodeStart":45,"sourceCodeEnd":72,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/dotnet/samples/GettingStartedWithProcesses/Utilities/ProcessStateMetadataUtilities.cs#L45-L72","documentation":"A KernelException thrown by StoreProcessStateLocally when fullFilepath does not have a '.json' extension (or has an empty extension). The serializer writes JSON, so a non-.json path is treated as a contract violation.","triggerScenarios":"Calling the save helper with a path whose extension is missing, empty, or not '.json' (e.g. 'state.txt', 'state').","commonSituations":"Filename built from a process name without appending '.json'; user-supplied filename of a different format; copy/paste path error.","solutions":["Ensure fullFilepath ends with '.json'.","Normalize: if (Path.GetExtension(path) != \".json\") path += \".json\"; before saving.","Document that only JSON output is supported."],"exampleFix":"// before\nStoreProcessStateLocally(state, \"processState\");\n// after\nstring path = \"processState\"; if (Path.GetExtension(path) != \".json\") path += \".json\";\nStoreProcessStateLocally(state, path);","handlingStrategy":"validation","validationCode":"if (!string.Equals(Path.GetExtension(fullFilepath), \".json\", StringComparison.OrdinalIgnoreCase))\n    fullFilepath += \".json\";","typeGuard":"bool HasJsonExtension(string p) => string.Equals(Path.GetExtension(p), \".json\", StringComparison.OrdinalIgnoreCase);","tryCatchPattern":"try { StoreProcessStateLocally(state, fullFilepath); }\ncatch (KernelException ex) when (ex.Message.Contains(\".json extension\")) { fullFilepath = Path.ChangeExtension(fullFilepath, \".json\"); /* retry */ }","preventionTips":["Always append '.json' when building process-state paths from names.","Validate extension at the input boundary.","Document the JSON-only contract."],"tags":["processes","filesystem","validation","kernel-exception"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}