-
Notifications
You must be signed in to change notification settings - Fork 4.7k
fix(codex): accept ChatGPT Edu Plus accounts #7869
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,6 +17,42 @@ export const JsonRpcResponseEnvelope = Schema.Struct({ | |
| error: Schema.optional(JsonRpcError), | ||
| }); | ||
|
|
||
| // Plan types emitted by the running codex binary can be newer than the pinned | ||
| // protocol schema (e.g. "edu_plus"). Upstream maps unrecognized plans to | ||
| // "unknown" via #[serde(other)]; mirror that so account payloads still decode. | ||
| const KNOWN_PLAN_TYPES = new Set([ | ||
| "free", | ||
| "go", | ||
| "plus", | ||
| "pro", | ||
| "prolite", | ||
| "team", | ||
| "self_serve_business_usage_based", | ||
| "business", | ||
| "enterprise_cbp_usage_based", | ||
| "enterprise", | ||
| "edu", | ||
| "unknown", | ||
| ]); | ||
|
|
||
| export const normalizeUnknownPlanTypes = (value: unknown): unknown => { | ||
| if (Array.isArray(value)) { | ||
| return value.map(normalizeUnknownPlanTypes); | ||
| } | ||
| if (typeof value !== "object" || value === null) { | ||
| return value; | ||
| } | ||
|
|
||
| return Object.fromEntries( | ||
| Object.entries(value).map(([key, child]) => [ | ||
| key, | ||
| key === "planType" && typeof child === "string" && !KNOWN_PLAN_TYPES.has(child) | ||
| ? "unknown" | ||
| : normalizeUnknownPlanTypes(child), | ||
|
Comment on lines
+49
to
+51
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When a decoded response or notification contains opaque tool data—such as MCP results or dynamic-tool arguments with an application field like Useful? React with 👍 / 👎. |
||
| ]), | ||
| ); | ||
| }; | ||
|
|
||
| export const decodeOptionalPayload = <A, I>( | ||
| method: string, | ||
| schema: Schema.Codec<A, I> | undefined, | ||
|
|
@@ -31,7 +67,9 @@ export const decodeOptionalPayload = <A, I>( | |
| ); | ||
| } | ||
|
|
||
| return Schema.decodeUnknownEffect(schema)(raw).pipe( | ||
| return Schema.decodeUnknownEffect(schema)( | ||
| typeof raw === "object" && raw !== null ? normalizeUnknownPlanTypes(raw) : raw, | ||
| ).pipe( | ||
|
Comment on lines
+70
to
+72
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Because every object-shaped call to AGENTS.md reference: AGENTS.md:L15-L17 Useful? React with 👍 / 👎. |
||
| Effect.mapError((error) => | ||
| CodexError.CodexAppServerRequestError.invalidPayload(method, "decode-payload", error), | ||
| ), | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟠 High
_internal/shared.ts:49normalizeUnknownPlanTypeschanges legitimate opaque payload data such as{ planType: "custom" }to{ planType: "unknown" }before handlers receive it. BecausedecodeOptionalPayloadapplies this recursively to every decoded payload, fields like toolarguments,structuredContent, realtime items, and web-search results are corrupted; restrict normalization to the actual account-plan fields or methods.🤖 Copy this AI Prompt to have your agent fix this: