Skip to content

Add FedCM Initiator Type - #3424

Merged
kblok merged 1 commit into
hardkoded:masterfrom
jsneedles:add-fedcm-initiator
Apr 27, 2026
Merged

kblok merged 1 commit into
hardkoded:masterfrom
jsneedles:add-fedcm-initiator

Conversation

@jsneedles

Copy link
Copy Markdown
Contributor

I started getting json serialization exceptions Unknown value 'FedCM' for enum InitiatorType

Looking at chrome dev tools protocol it is indeed there.

So, I added it to the enum.

I wasn't sure if we wanted Other to be last always or to maintain its numeric order... so I was conservative and put FedCm at the end.

@kblok
kblok requested a review from Copilot April 26, 2026 19:30

@kblok kblok left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds support for the Chrome DevTools Protocol Network.Initiator.type value FedCM to avoid JSON deserialization failures when that initiator type appears.

Changes:

  • Added FedCm to InitiatorType with an EnumMember mapping to the protocol string "FedCM".

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +44 to +48
/// <summary>
/// FedCM.
/// </summary>
[EnumMember(Value = "FedCM")]
FedCm,

Copilot AI Apr 26, 2026

Copy link

Choose a reason for hiding this comment

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

Consider adding a small unit test that deserializes a Network.Initiator payload with type: "FedCM" and asserts it maps to InitiatorType.FedCm. The existing tests around initiators exercise Other/Parser/Script (e.g., lib/PuppeteerSharp.Tests/NetworkTests/RequestInitiatorTests.cs), but none cover this new protocol value that previously caused failures.

Copilot uses AI. Check for mistakes.
Comment on lines 39 to +48
/// <summary>
/// Other.
/// </summary>
Other,

/// <summary>
/// FedCM.
/// </summary>
[EnumMember(Value = "FedCM")]
FedCm,

Copilot AI Apr 26, 2026

Copy link

Choose a reason for hiding this comment

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

This enum still throws for any future CDP initiator types that aren’t yet modeled (via EnumHelper.FromValueString). If the intent is to be resilient to protocol additions, consider adding [DefaultEnumValue((int)Other)] on the enum (similar to TargetType and DOMWorldType) so unknown values fall back to Other instead of throwing.

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@copilot apply changes based on this feedback

@kblok
kblok merged commit 5bc4e3f into hardkoded:master Apr 27, 2026
18 of 19 checks passed
kblok added a commit that referenced this pull request Apr 27, 2026
* feat: add FedCm to InitiatorType and add DefaultEnumValue fallback

Add FedCm enum member with [EnumMember(Value = "FedCM")] to prevent
JSON deserialization failures when Chrome sends this initiator type.
Also add [DefaultEnumValue((int)Other)] so any future unknown CDP
initiator types gracefully fall back to Other instead of throwing.

Closes #3424

* Remove FedCm from InitiatorType enum

Removed FedCm enum value from InitiatorType.
@jsneedles

Copy link
Copy Markdown
Contributor Author

Hey @kblok just out of curiosity, why remove the explicit FedCM?

I understand adding the fallback for the future, but seems worthwhile to differentiate when known?

@kblok

kblok commented Apr 27, 2026

Copy link
Copy Markdown
Member

Hey @kblok just out of curiosity, why remove the explicit FedCM?

I understand adding the fallback for the future, but seems worthwhile to differentiate when known?

Hmmm I didn't remove it, did I?

@jsneedles

Copy link
Copy Markdown
Contributor Author

Hey @kblok just out of curiosity, why remove the explicit FedCM?

I understand adding the fallback for the future, but seems worthwhile to differentiate when known?

Hmmm I didn't remove it, did I?

Nope, my bad!

I was misreading on mobile and saw the remove commit without the add back in... checked main and it's there!

Thanks again 💯

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.

3 participants