Schema.isBase64 / isBase64Url throw RangeError on multi-megabyte strings
I maintainer di solito rispondono entro 1 giorno
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 20/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Ferma
- Stack tecnologico
- typescript
Direzione di ricerca
Start with the Base64 and Base64Url checks in the Schema string checks and their existing tests. The issue shows the repeated-group regex throws on large valid inputs while flat character checks and the encoding decoders do not; compare those approaches and run the relevant Schema tests. Done means both checks handle multi-megabyte valid input without throwing and reject invalid input as a schema issue.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
What version of Effect is running?
4.0.5 (also current main, bbedfc71c0)
What steps can reproduce the bug?
import { Schema } from "effect"
const input = "A".repeat(4_000_000) // valid Base64 / Base64Url, ~3 MB decoded
Schema.decodeUnknownSync(Schema.String.check(Schema.isBase64()))(input)
Schema.decodeUnknownSync(Schema.String.check(Schema.isBase64Url()))(input)
What is the expected behavior?
Both decode successfully (or fail with a schema issue for invalid input).
What do you see instead?
- 4.0.5:
RangeError: Maximum call stack size exceeded main:Error: Sync adapter can only throw schema errors, causeCause([Die(RangeError: Maximum call stack size exceeded)]).Schema.isanddecodeUnknownResultthrow too.
Additional information
The bare regex throws as well, so the problem is the pattern, not Schema:
/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/.test("A".repeat(4_000_000))
// RangeError: Maximum call stack size exceeded
V8's regexp engine keeps backtracking state for each iteration of the repeated (...{4})* group. On Node v24.21.0 (V8 13.6), both patterns accept 3,728,260 chars and throw from 3,728,264 chars (932,066 groups, ~2.67 MiB decoded). Base64 strings produced by Buffer#toString("base64") fail at the same length. The limit stays the same with --stack-size=400 and --stack-size=4000. Non-capturing (?:...) groups also throw at 8M chars. A flat ^[0-9a-zA-Z+/]*$ does not, and neither do Base64.decode / Base64Url.decode from effect/encoding (~20 ms at 8M chars).
In practice, Base64 payloads such as file attachments above ~2.7 MB cannot be validated. I checked the other regex-backed string checks (isTrimmed, isUUID, isGUID, isULID, isStringFinite, isStringBigInt, isStringSymbol, isUppercased, isCapitalized, isStartingWith) on 8M-char inputs, and none of them throw.
- Lingua principale
- TypeScript
- Stelle
- 16.7k
- Fork
- 808
- Merge medio
- 10h 7m
- PR unite (30g)
- 808
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di Effect-TS/effect
-
Support {self: this} for fnUntracedForse già presa @ArjunCodess l’ha presa 32 giorni fa. Apertaenhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
Effect-TS/effect#8101 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
v4 Cache.get: a caller that joins an abandoned lookup fails with an interruption it did not ask forAperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 42/100
I maintainer di solito rispondono entro 1 giorno
-
Typed unix socket and TLS options for `BunHttpClient` and `DenoHttpClient`Forse già presa @effect-bot l’ha presa oggi. Apertadocker-made-me-do-it enhancement platform
Effect-TS/effect#9687 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
RFC 9457 Problem Details for HttpApi errorsForse già presa @effect-bot l’ha presa oggi. Apertadocker-made-me-do-it enhancement
Difficoltà 5/5 Più di una settimana Idoneità per principianti 20/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di Effect-TS/effect
Issue simili
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
endora-commerce/endora-commerce#397 ·
I maintainer di solito rispondono entro 1 giorno
-
level/task
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
wazuh/wazuh-dashboard-plugins#9472 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 63/100
I maintainer di solito rispondono entro 1 giorno
-
ready-for-agent
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
xavxyz/bei-shan-lin-shui#57 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
opennextjs/opennextjs-cloudflare#1461 ·
I maintainer di solito rispondono entro 1 giorno