Skip to content

Kiota-generated client fails with CS0103 for Status

One-sentence summary: update the API provider's @saif/platform-typespec to 3.8.0 or later to resolve this Status/CS0103 error, republish its OpenAPI document, and regenerate the consuming client; 3.8.0 through 3.9.2 still carry a related Type defect (see note below), so prefer 3.9.3 or later if you want both fixed.


🚨 Symptom

Generating a C# client with Kiota 1.32.0 or later succeeds, but the generated client fails to compile:

error CS0103: The name 'Status' does not exist in the current context

This can appear after saif doctor fix updates the globally installed Kiota CLI, or during a build that regenerates a <KiotaReference> from an affected API's published OpenAPI document. Updating packages in the consuming .NET project does not correct an already-published OpenAPI document.


📌 Applies to

Aspect Value
Component APIs publishing OpenAPI from TypeSpec and C# clients generated with Kiota
Forge versions API provider's TypeSpec project uses @saif/platform-typespec earlier than 3.8.0; 3.8.0 resolves this Status defect but 3.8.0 through 3.9.2 still carry the related Type defect described below, so prefer 3.9.3 or later
Related versions Kiota 1.32.0 or later; check the version compatibility matrix

🧠 Cause

Kiota 1.32.0 began initializing numeric and Boolean properties from their OpenAPI default values. OpenAPI documents generated with earlier versions of @saif/platform-typespec declare status on both the shared ProblemDetails schema and each concrete error schema. Kiota removes the duplicate child property but still generates its constructor initializer, leaving an assignment to a Status property that does not exist.

The incompatible model comes from the API provider's published OpenAPI document, not from the consuming API's Forge or .NET package versions.

A related defect affects type

3.8.0 fixed status by moving it off the base and anchoring the base body with type instead, which left type declared in both places. With Kiota 1.35.0, documents generated with 3.8.0 through 3.9.2 produce C# platform error models without a Type property. This missing property does not itself cause a build error. Those package releases do not include the separate type fix; upgrading only to 3.8.0 resolves Status, not Type. See Duplicate properties are dropped from generated clients for the required schema correction and server compatibility impact.


✅ Fix

  1. Find the API provider whose OpenAPI document is referenced by the failing <KiotaReference>.

  2. In that API provider's TypeSpec project, update @saif/platform-typespec to a version that includes both fixes:

    npm install @saif/platform-typespec@^3.9.3
    

    If you are only chasing the Status/CS0103 symptom in this article and don't need the Type fix, @saif/platform-typespec@^3.8.0 is also sufficient, but that range can resolve to 3.8.0-3.9.2, which still carries the Type defect described above.

  3. Rebuild the TypeSpec project and publish the regenerated OpenAPI document through the API provider's normal delivery pipeline:

    npm run build
    
  4. After the referenced OpenAPI URL serves the updated document, clean and rebuild the consuming .NET project so Kiota regenerates the client:

    dotnet clean
    dotnet build
    

🔬 Verify

Confirm both regressions are resolved in the published OpenAPI document:

  • status is declared only on each concrete error schema (e.g. BadRequest), not on the shared ProblemDetails schema.
  • type is declared only on the shared ProblemDetails schema, and each concrete error schema references it through allOf inheritance rather than redeclaring it locally.

The regenerated client then builds without CS0103, and each concrete error model exposes both its own Status property and a Type property:

Build succeeded.
    0 Error(s)