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:
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¶
-
Find the API provider whose OpenAPI document is referenced by the failing
<KiotaReference>. -
In that API provider's TypeSpec project, update
@saif/platform-typespecto a version that includes both fixes:If you are only chasing the
Status/CS0103 symptom in this article and don't need theTypefix,@saif/platform-typespec@^3.8.0is also sufficient, but that range can resolve to 3.8.0-3.9.2, which still carries theTypedefect described above. -
Rebuild the TypeSpec project and publish the regenerated OpenAPI document through the API provider's normal delivery pipeline:
-
After the referenced OpenAPI URL serves the updated document, clean and rebuild the consuming .NET project so Kiota regenerates the client:
🔬 Verify¶
Confirm both regressions are resolved in the published OpenAPI document:
statusis declared only on each concrete error schema (e.g.BadRequest), not on the sharedProblemDetailsschema.typeis declared only on the sharedProblemDetailsschema, and each concrete error schema references it throughallOfinheritance 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:
📚 Related¶
- Downstream API Calls
- saif-corp/forge#904 — fix shipped in
@saif/platform-typespec3.8.0 - saif-corp/forge#1181 — tracks the remaining Kiota generator/runtime version-alignment gap
- microsoft/kiota#7404 — introduced initialization from OpenAPI default values
- Microsoft Teams support thread