Skip to content

Commit 440b24f

Browse files
committed
fix(msteams): prevent toPluginJsonValue from crashing on unserializable values
toPluginJsonValue serializes plugin values through JSON.stringify+parse without a try/catch guard, so BigInt, circular references, or other unserializable values cause an unhandled TypeError that propagates to the caller and may tear down the MSTeams plugin runtime. Wrap the JSON round-trip in try/catch and return the original value when serialization fails, matching the defensive pattern already used by toCodeModeJsonSafe.
1 parent 756de70 commit 440b24f

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

extensions/msteams/src/sqlite-state.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,12 @@ export function resolveMSTeamsSqliteStateEnv(
4343
}
4444

4545
export function toPluginJsonValue<T>(value: T): T {
46-
const serialized = JSON.stringify(value);
47-
return JSON.parse(serialized) as T;
46+
try {
47+
const serialized = JSON.stringify(value);
48+
return JSON.parse(serialized) as T;
49+
} catch {
50+
return value;
51+
}
4852
}
4953

5054
function resolveMSTeamsSqliteStateDir(options: MSTeamsSqliteStateOptions | undefined): string {

0 commit comments

Comments
 (0)