microsoft/semantic-kernel · warning · KernelException

Filepath for process {processStateInfo.Name} does not have .

Error message

Filepath for process {processStateInfo.Name} does not have .json extension

What it means

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.

Source

Thrown at dotnet/samples/GettingStartedWithProcesses/Utilities/ProcessStateMetadataUtilities.cs:63

        return filepath;
    }

    /// <summary>
    /// Function that stores the definition of the SK Process State`.<br/>
    /// </summary>
    /// <param name="processStateInfo">Process State to be stored</param>
    /// <param name="fullFilepath">Filepath to store definition of process in json format</param>
    private static void StoreProcessStateLocally(KernelProcessStateMetadata processStateInfo, string fullFilepath)
    {
        if (!(Path.GetDirectoryName(fullFilepath) is string directory && Directory.Exists(directory)))
        {
            throw new KernelException($"Directory for path '{fullFilepath}' does not exist, could not save process {processStateInfo.Name}");
        }

        if (!(Path.GetExtension(fullFilepath) is string extension && !string.IsNullOrEmpty(extension) && extension == ".json"))
        {
            throw new KernelException($"Filepath for process {processStateInfo.Name} does not have .json extension");
        }

        string content = JsonSerializer.Serialize(processStateInfo, s_jsonOptions);
        Console.WriteLine($"Process State: \n{content}");
        Console.WriteLine($"Saving Process State Locally: \n{Path.GetFullPath(fullFilepath)}");
        File.WriteAllText(fullFilepath, content);
    }
}

View on GitHub (pinned to c028a0c7dc)

Solutions

  1. Ensure fullFilepath ends with '.json'.
  2. Normalize: if (Path.GetExtension(path) != ".json") path += ".json"; before saving.
  3. Document that only JSON output is supported.

Example fix

// before
StoreProcessStateLocally(state, "processState");
// after
string path = "processState"; if (Path.GetExtension(path) != ".json") path += ".json";
StoreProcessStateLocally(state, path);
Defensive patterns

Strategy: validation

Validate before calling

if (!string.Equals(Path.GetExtension(fullFilepath), ".json", StringComparison.OrdinalIgnoreCase))
    fullFilepath += ".json";

Type guard

bool HasJsonExtension(string p) => string.Equals(Path.GetExtension(p), ".json", StringComparison.OrdinalIgnoreCase);

Try / catch

try { StoreProcessStateLocally(state, fullFilepath); }
catch (KernelException ex) when (ex.Message.Contains(".json extension")) { fullFilepath = Path.ChangeExtension(fullFilepath, ".json"); /* retry */ }

Prevention

When it happens

Trigger: Calling the save helper with a path whose extension is missing, empty, or not '.json' (e.g. 'state.txt', 'state').

Common situations: Filename built from a process name without appending '.json'; user-supplied filename of a different format; copy/paste path error.

Related errors


AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13). Data as JSON: /api/errors/6df62062e0d91e45. Report an issue: GitHub.