Schema: idiomatic way to encode against a type-erased `Schema.Top` (codec services show as `unknown` in the requirements channel)?
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 35/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Tranquilla
- Stack tecnologico
- typescript
- Ambito
- api
Direzione di ricerca
Start with the Schema.Top, Schema.toCodecJson, Schema.encodeUnknownEffect, encodeUnknownExit, and encodeUnknownResult APIs, then run the linked reproduction with bun install and bun run repro. Compare the reported R=unknown and R=never assertions and runtime check; done would require an agreed idiomatic way to encode or decode service-free type-erased schemas without an unsafe cast.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
This is a usage/idiom question about encoding against type-erased schemas.
When you only have a type-erased Schema.Top — e.g. from RPC dynamic dispatch, heterogeneous registries, or plugin systems where the concrete schema type is lost — encoding a value against it as JSON surfaces unknown in the requirements (R) channel:
declare const erased: Schema.Top
const eff = Schema.encodeUnknownEffect(Schema.toCodecJson(erased))(value)
// eff: Effect<Json, SchemaError, unknown> // <- unknown in R
Schema.Top types DecodingServices/EncodingServices as unknown, and toCodecJson + encodeUnknownEffect forward them into R. @effect/language-service flags it as anyUnknownInErrorContext (TS377030, "unknown in the requirements channel"). But such schemas are plain data — they need no codec services (the repro verifies this at runtime).
The only clean fix we found is an unsafe cast asserting the (true) never service channels:
Schema.toCodecJson(erased as Schema.Codec<unknown, unknown, never, never>)
// -> Effect<Json, SchemaError, never>
We confirmed encodeUnknownExit / encodeUnknownResult (which return Exit/Result with no R channel) don't avoid the cast — their ConstraintEncoder<unknown> bound requires EncodingServices extends never, which Schema.Top doesn't satisfy.
Question: is casting the service channels the idiomatic way to encode/decode against a Schema.Top known to need no services, or is there a cleaner, more Effect-native API for this (a service-erasing combinator, an encode variant that ignores services, a better way to type-erase RPC schemas, etc.)?
Reproduction
https://github.com/schickling-repros/2026-07-effect-erased-schema-services
bun install
bun run repro # tsc type-assertions (R=unknown vs R=never) + a runtime check
Versions
- effect:
4.0.0-beta.98 @effect/language-service:anyUnknownInErrorContext(TS377030)
Context: this arises encoding RPC exit/payload schemas after dynamic dispatch erases them to Schema.Top — a follow-on to #6064 (which exposed successSchema but not the service-typing question).
Posted on behalf of @schickling
| field | value |
|---|---|
agent_name |
🌲 cl1-pine |
agent_session_id |
b9f1f4a5-dd10-40f6-b25c-945e71e2007a |
agent_tool |
Claude Code |
agent_tool_version |
2.1.206 |
agent_runtime |
Claude Code 2.1.206 |
agent_model |
claude-opus-4-8 |
runtime_profile |
/nix/store/1n76sy6i9y3ki3k4w04jksqvygw67sj0-coding-agent-runtime-profile/share/coding-agents/profile.json |
skills_manifest |
/nix/store/jn6r0r7r59x3a525jch4pwzwykszqp60-agent-skills-corpus/share/agent-skills/manifest.json |
worktree |
livestore/schickling/2026-07-17-refactor |
machine |
dev3 |
tooling_profile |
dotfiles@4eac376 |
- Lingua principale
- TypeScript
- Stelle
- 16.7k
- Fork
- 808
- Merge medio
- 10h 13m
- PR unite (30g)
- 800
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
-
RpcTest.makeClient: accept disableFatalDefectsForse già presa @effect-bot l’ha presa 2 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
Effect-TS/effect#9893 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
@effect/ai-anthropic: responses whose usage has only input_tokens and output_tokens fail to decode (Anthropic-compatible gateways)Forse già presa @effect-bot l’ha presa oggi. Aperta
Effect-TS/effect#9963 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
McpClient rejects McpServer's method-not-found response and fails later stdio requestsForse già presa @effect-bot l’ha presa oggi. Aperta
Effect-TS/effect#9958 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
SQLite withTransaction: interrupting a queued transaction as it gets the connection leaks the connectionForse già presa @effect-bot l’ha presa oggi. Aperta
Difficoltà 4/5 1-2 giorni Idoneità per principianti 35/100
I maintainer di solito rispondono entro 1 giorno
-
ClickhouseMigrator records migrations as done before running them, so a failed migration is skipped on the next runForse già presa @effect-bot l’ha presa oggi. Aperta
Effect-TS/effect#9956 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di Effect-TS/effect
Issue simili
-
支持对已取消(cancelled)任务生成报告Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
Clouditera/VulnHunter#57 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
bug bug:behavior clawsweeper:bulk-filed clawsweeper:fix-shape-clear clawsweeper:no-new-fix-pr clawsweeper:source-repro impact:auth-provider issue-rating: 🦞 diamond lobster P2
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
openclaw/openclaw#185297 · 1 commento · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
-
bug needs-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
apex-dev-tools/apex-log-parser#199 ·
I maintainer di solito rispondono entro 1 giorno