Skip to content

Fix Ruby isStream always evaluating to false in CodeMethodWriter#7639

Merged
baywet merged 1 commit into
microsoft:mainfrom
hobostay:fix/ruby-isstream-always-false
Apr 22, 2026
Merged

Fix Ruby isStream always evaluating to false in CodeMethodWriter#7639
baywet merged 1 commit into
microsoft:mainfrom
hobostay:fix/ruby-isstream-always-false

Conversation

@hobostay
Copy link
Copy Markdown
Contributor

Summary

  • Fix incorrect comparison in Ruby/CodeMethodWriter.cs where conventions.StreamTypeName.Equals(StringComparison.OrdinalIgnoreCase) was passing the StringComparison enum value instead of the returnType string
  • This caused isStream to always be false, meaning Ruby SDKs generated by Kiota would never use send_primitive_async for stream/binary responses

Problem

The buggy code:

var isStream = conventions.StreamTypeName.Equals(StringComparison.OrdinalIgnoreCase);

This calls string.Equals(object, StringComparison) which compares the string "stdin" against the enum value StringComparison.OrdinalIgnoreCase. Since a string is never equal to an enum, this always returns false.

Fix

Aligns with all other language writers (CSharp, Python, Dart, PHP, TypeScript) which correctly compare the return type:

var isStream = conventions.StreamTypeName.Equals(returnType, StringComparison.OrdinalIgnoreCase);

Test plan

  • Verify existing Ruby writer tests still pass
  • Verify that Ruby code generation now correctly uses send_primitive_async for stream return types

🤖 Generated with Claude Code

@hobostay hobostay requested a review from a team as a code owner April 21, 2026 12:04
Copy link
Copy Markdown
Member

@baywet baywet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution!

@baywet baywet force-pushed the fix/ruby-isstream-always-false branch from 744b999 to 80134c4 Compare April 22, 2026 13:32
@baywet baywet enabled auto-merge (squash) April 22, 2026 13:33
The comparison `conventions.StreamTypeName.Equals(StringComparison.OrdinalIgnoreCase)` was passing the enum value instead of the returnType string. This caused `isStream` to always be false, meaning Ruby SDKs generated by Kiota would never use `send_primitive_async` for stream responses and always fall back to `send_async`.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@baywet baywet force-pushed the fix/ruby-isstream-always-false branch from 80134c4 to de3ed06 Compare April 22, 2026 14:03
@baywet baywet merged commit 50d819d into microsoft:main Apr 22, 2026
297 checks passed
hobostay pushed a commit to hobostay/kiota that referenced this pull request Apr 23, 2026
Remove unrelated CHANGELOG entries (microsoft#7643, microsoft#7642, microsoft#7639) that don't
belong to this PR. Add C# and Dart writer tests verifying that union
model factory methods skip discriminator branches when the mapping key
is null/empty (i.e. an unmapped complex type).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
baywet added a commit that referenced this pull request Apr 23, 2026
…generation (#7641)

* Fix potential NullReferenceException in C# union model discriminator generation

When no discriminator mapping is found for a property type, `FirstOrDefault` returns a default KeyValuePair with a null key. Accessing `mappedType.Key` without a null check could generate invalid C# code with empty discriminator strings.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* fix: discriminator null key for other languages

* docs: adds changelog entries for the recent fixes

* fix: badly structured code after discriminator key fix

* Add regression tests for unmapped complex types in union factory methods

Remove unrelated CHANGELOG entries (#7643, #7642, #7639) that don't
belong to this PR. Add C# and Dart writer tests verifying that union
model factory methods skip discriminator branches when the mapping key
is null/empty (i.e. an unmapped complex type).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* docs: restores missing changelog entries

---------

Co-authored-by: Test User <test@example.com>
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
Co-authored-by: Vincent Biret <vibiret@microsoft.com>
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.

2 participants