Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(codex): accept ChatGPT Edu Plus accounts #7869

ClosedExotic209093(GitHub profile, opens in a new tab)wants to merge 2 commits intomain fromrefs/pull/7869/headopened View on GitHub

Showing 6 changed files with 147 additions and 1 deletion (loading 2).

x
0 of 6 viewed, 6 left
40 additions and 1 deletionpackages/effect-codex-app-server/scripts/generate.tsModified
View file
@@ -183,6 +183,44 @@
return yield* decodeGithubContentEntries(raw);
});
​
+// Plan-type enums are `#[serde(other)]` catch-alls upstream: a codex binary newer
+// than the pinned protocol ref emits members this schema does not list (e.g.
+// "edu_plus", added in codex 0.148.0). Decode those to the catch-all member the
+// way serde does, so one unrecognised plan cannot fail the whole account payload.
+const FORWARD_COMPATIBLE_ENUM_PATTERN = /__PlanType$/;
+const FORWARD_COMPATIBLE_FALLBACK = "unknown";
+​
+function applyForwardCompatibleEnum(name: string, code: string): string {
+ if (!FORWARD_COMPATIBLE_ENUM_PATTERN.test(name)) {
+ return code;
+ }
+​
+ const [typeLine, constLine] = code.split("\n");
+ if (typeLine === undefined || constLine === undefined) {
+ throw new Error(`Malformed schema entry for ${name}`);
+ }
+​
+ const match = /^(export const [A-Za-z0-9_]+ = )Schema\.Literals\((\[[^\]]*\])\)(.*)$/.exec(
+ constLine,
+ );
+ if (!match?.[1] || !match[2] || match[3] === undefined) {
+ throw new Error(
+ `Expected ${name} to be a literal union so the serde catch-all fallback can be applied`,
+ );
+ }
+​