Fix ZDR issue for openai - #1059
Merged
Merged
MacroscopeApp / Review for correctness
succeeded
Dec 4, 2025 in 3m 22s
2 issues identified (4 code objects reviewed).
• Merge Base:
28df057
• Head:648e8c3
Details
| ✅ | File Path | Comments Posted |
|---|---|---|
| ✅ | apps/web/env.ts |
0 |
| ❌ | apps/web/utils/llms/model.ts |
1 |
| ❌ | apps/web/utils/outlook/client.ts |
1 |
Filtered Issues Details
apps/web/env.ts
- line 149:
NEXT_PUBLIC_FREE_UNSUBSCRIBE_CREDITSis defined asz.number().default(5)on the client (line 149) but the corresponding value inexperimental__runtimeEnvis sourced fromprocess.env.NEXT_PUBLIC_FREE_UNSUBSCRIBE_CREDITS, which is always a string when set. Withoutz.coerce.number(), providing an env var like"5"will fail validation at runtime instead of being parsed to a number. All other client numeric envs usez.coerce.number(); this one is inconsistent and will cause a runtime parse error when set. [ Out of scope ]
apps/web/utils/llms/model.ts
- line 92:
providerOptionsis accepted byselectModelbut is only forwarded in theProvider.OPEN_AIandProvider.OPENROUTERbranches. ForGOOGLE,GROQ,AI_GATEWAY,BEDROCK, andANTHROPIC, any providedproviderOptionsare silently ignored, which breaks interface parity and may lead callers to believe options are applied when they are not. Either document the asymmetry or forward/validate options consistently. [ Low confidence ] - line 355:
getBackupModelconstructs an OpenRouter client usingenv.OPENROUTER_API_KEYwithout checking if it exists. IfOPENROUTER_BACKUP_MODELis set butOPENROUTER_API_KEYis missing, the backup model is created with an undefined API key, likely causing runtime failures when used. Add a check to require the API key or returnnull. [ Low confidence ]
apps/web/utils/outlook/client.ts
- line 126: Refresh token request may be rejected by Microsoft because it omits the
scopeparameter for thegrant_type=refresh_tokenrequest to the v2.0 token endpoint. This can lead toinvalid_request/invalid_grantresponses depending on tenant/app configuration. [ Low confidence ] - line 192:
saveTokensis called before validating the token response. Iftokens.access_tokenis missing or empty,createOutlookClient(tokens.access_token)will throw aSafeError, but the function will have already persisted an invalidaccess_token/expires_at, leaving state in a bad/partially updated condition. [ Low confidence ] - line 195: Potential NaN for
expires_at:Math.floor(Date.now() / 1000 + tokens.expires_in)assumestokens.expires_inis a finite number. If it is missing or not numeric, the result will beNaNand be stored, breaking future expiry checks. [ Low confidence ]
Loading