Skip to content

[TypeScript] Error "Namespace not found for return type" for NOTION.COM api #7802

Description

@WolfgangHG

What are you generating using Kiota, clients or plugins?

API Client/SDK

In what context or format are you using Kiota?

Nuget tool

Client library/SDK language

None

Describe the bug

Found as part of #7774

It fails with an error:

crit: Kiota.Builder.KiotaBuilder[0]
      error generating the client: Namespace not found for return type
      System.InvalidOperationException: Namespace not found for return type
         at Kiota.Builder.Writers.TypeScript.CodeFunctionWriter.FindFunctionInNameSpace(String functionName, CodeElement codeElement, CodeType returnType) in E:\Projekte\Github\kiota\src\Kiota.Builder\Writers\TypeScript\CodeFunctionWriter.cs:line 443
         at Kiota.Builder.Writers.TypeScript.CodeFunctionWriter.GetDeserializerFunctionName(CodeElement codeElement, CodeType returnType) in E:\Projekte\Github\kiota\src\Kiota.Builder\Writers\TypeScript\CodeFunctionWriter.cs:line 436
         at Kiota.Builder.Writers.TypeScript.CodeFunctionWriter.WriteComposedTypeDeserializer(CodeFunction codeElement, LanguageWriter writer, CodeParameter composedParam, CodeFile codeFile) in E:\Projekte\Github\kiota\src\Kiota.Builder\Writers\TypeScript\CodeFunctionWriter.cs:line 154
         at Kiota.Builder.Writers.TypeScript.CodeFunctionWriter.WriteDeserializerFunction(CodeFunction codeFunction, CodeFile codeFile, LanguageWriter writer) in E:\Projekte\Github\kiota\src\Kiota.Builder\Writers\TypeScript\CodeFunctionWriter.cs:line 667
         at Kiota.Builder.Writers.TypeScript.CodeFunctionWriter.WriteCodeElement(CodeFunction codeElement, LanguageWriter writer) in E:\Projekte\Github\kiota\src\Kiota.Builder\Writers\TypeScript\CodeFunctionWriter.cs:line 115
         at Kiota.Builder.Writers.LanguageWriter.Write[T](T code) in E:\Projekte\Github\kiota\src\Kiota.Builder\Writers\LanguageWriter.cs:line 149
         at Kiota.Builder.CodeRenderers.CodeRenderer.RenderCode(LanguageWriter writer, CodeElement element) in E:\Projekte\Github\kiota\src\Kiota.Builder\CodeRenderers\CodeRenderer.cs:line 83
         at Kiota.Builder.CodeRenderers.CodeRenderer.RenderCode(LanguageWriter writer, CodeElement element) in E:\Projekte\Github\kiota\src\Kiota.Builder\CodeRenderers\CodeRenderer.cs:line 88
         at Kiota.Builder.CodeRenderers.CodeRenderer.RenderCodeNamespaceToSingleFileAsync(LanguageWriter writer, CodeElement codeElement, String outputFile, CancellationToken cancellationToken) in E:\Projekte\Github\kiota\src\Kiota.Builder\CodeRenderers\CodeRenderer.cs:line 35
         at Kiota.Builder.CodeRenderers.CodeRenderer.RenderCodeNamespaceToSingleFileAsync(LanguageWriter writer, CodeElement codeElement, String outputFile, CancellationToken cancellationToken) in E:\Projekte\Github\kiota\src\Kiota.Builder\CodeRenderers\CodeRenderer.cs:line 37
         at Kiota.Builder.CodeRenderers.CodeRenderer.RenderCodeNamespaceToFilePerClassAsync(LanguageWriter writer, CodeNamespace currentNamespace, CancellationToken cancellationToken) in E:\Projekte\Github\kiota\src\Kiota.Builder\CodeRenderers\CodeRenderer.cs:line 55
         at Kiota.Builder.CodeRenderers.CodeRenderer.RenderCodeNamespaceToFilePerClassAsync(LanguageWriter writer, CodeNamespace currentNamespace, CancellationToken cancellationToken) in E:\Projekte\Github\kiota\src\Kiota.Builder\CodeRenderers\CodeRenderer.cs:line 59
         at Kiota.Builder.CodeRenderers.CodeRenderer.RenderCodeNamespaceToFilePerClassAsync(LanguageWriter writer, CodeNamespace currentNamespace, CancellationToken cancellationToken) in E:\Projekte\Github\kiota\src\Kiota.Builder\CodeRenderers\CodeRenderer.cs:line 59
         at Kiota.Builder.CodeRenderers.CodeRenderer.RenderCodeNamespaceToFilePerClassAsync(LanguageWriter writer, CodeNamespace currentNamespace, CancellationToken cancellationToken) in E:\Projekte\Github\kiota\src\Kiota.Builder\CodeRenderers\CodeRenderer.cs:line 59
         at Kiota.Builder.KiotaBuilder.CreateLanguageSourceFilesAsync(GenerationLanguage language, CodeNamespace generatedCode, CancellationToken cancellationToken) in E:\Projekte\Github\kiota\src\Kiota.Builder\KiotaBuilder.cs:line 668
         at Kiota.Builder.KiotaBuilder.<>c__DisplayClass21_0.<<GenerateClientAsync>b__0>d.MoveNext() in E:\Projekte\Github\kiota\src\Kiota.Builder\KiotaBuilder.cs:line 311
      --- End of stack trace from previous location ---
         at Kiota.Builder.KiotaBuilder.GenerateConsumerAsync(Func`5 innerGenerationSteps, CancellationToken cancellationToken) in E:\Projekte\Github\kiota\src\Kiota.Builder\KiotaBuilder.cs:line 348
         at Kiota.Builder.KiotaBuilder.GenerateConsumerAsync(Func`5 innerGenerationSteps, CancellationToken cancellationToken) in E:\Projekte\Github\kiota\src\Kiota.Builder\KiotaBuilder.cs:line 368
         at Kiota.Builder.KiotaBuilder.GenerateClientAsync(CancellationToken cancellationToken) in E:\Projekte\Github\kiota\src\Kiota.Builder\KiotaBuilder.cs:line 285
         at kiota.Handlers.KiotaGenerateCommandHandler.InvokeAsync(ParseResult parseResult, CancellationToken cancellationToken) in E:\Projekte\Github\kiota\src\kiota\Handlers\KiotaGenerateCommandHandler.cs:line 166

Expected behavior

No error, client should be generated

How to reproduce

After having built Kiota, execute this:

.\it\generate-code.ps1 -descriptionUrl https://developers.notion.com/openapi.json  -language "typescript" -dev

Open API description file

https://developers.notion.com/openapi.json

Kiota Version

source code build dated 2026-06-15

Latest Kiota version known to work for scenario above?(Not required)

No response

Known Workarounds

No response

Configuration

No response

Debug output

No response

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    status:waiting-for-triageAn issue that is yet to be reviewed or assignedtype:bugA broken experience

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    Status
    Needs Triage 🔍

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions