Skip to content

Fix missing (de)serializer registration after workspace refresh - #7996

Draft
Gavin Barron (gavinbarron) with Copilot wants to merge 2 commits into
mainfrom
copilot/refresh-typescript-client-serializer-registration
Draft

Fix missing (de)serializer registration after workspace refresh#7996
Gavin Barron (gavinbarron) with Copilot wants to merge 2 commits into
mainfrom
copilot/refresh-typescript-client-serializer-registration

Conversation

Copilot AI commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

When running kiota client generate --refresh, the generated TypeScript client had empty if blocks for serializer/deserializer registration, causing compile errors.

Root cause

BaseApiConsumerConfiguration.UpdateGenerationConfigurationFromBase was clearing the default serializer/deserializer collections:

config.Serializers.Clear();
config.Deserializers.Clear();

Language refiners replace the C# defaults with language-specific ones only when the collection matches the defaults in count and content:

if (modules.Count == initialNames.Count && modules.All(initialNames.Contains))
{
    propertySetter.Invoke(currentMethod, moduleNames);  // never reached
}

After clearing (count = 0), the condition 0 == 4 always fails — no replacement happens, and the generated client emits empty registration blocks.

Fix

  • BaseApiConsumerConfiguration.cs — Remove the two Clear() calls. A fresh GenerationConfiguration is always constructed before calling UpdateGenerationConfigurationFromApiClientConfiguration, so the C# defaults are always present and available for language refiners to replace.
  • ApiClientConfigurationTests.cs — Update the assertion to verify defaults are preserved (NotEmpty) rather than cleared.

…kspace config

Removes the Serializers.Clear() and Deserializers.Clear() calls from
UpdateGenerationConfigurationFromBase that were incorrectly clearing
the default serializer/deserializer collections. These defaults are
needed by ReplaceDefaultSerializationModules/ReplaceDefaultDeserializationModules
in language refiners to replace C# defaults with language-specific ones.

When using `kiota client generate --refresh`, a fresh GenerationConfiguration
is created with C# defaults, then UpdateGenerationConfigurationFromBase was
called which cleared those defaults. The TypeScript refiner checks if the
modules match the default count before replacing them - since they were
empty (count 0), no replacement happened and the generated client had
empty if-blocks for (de)serializer registration.

Fixes #7584
Copilot AI requested review from Copilot and removed request for Copilot July 27, 2026 21:52
Copilot AI changed the title [WIP] Fix TypeScript clients serialization issue during refresh Fix missing (de)serializer registration after workspace refresh Jul 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refreshing TypeScript clients in workspace removes (de)serializer registration

2 participants