feat: fully migrate to @sentry/api SDK types (remove all as-unknown-as casts)
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, backend-api-design, cli
Direzione di ricerca
Leggi src/lib/api/infrastructure.ts e i chiamanti sotto src/lib/api/ per comprendere il lavoro generico di unwrapResult e i cast rimanenti. Controlla le modifiche necessarie allo schema del backend in getsentry/sentry e sentry#116836 prima di rimuovere i cast dipendenti; il lavoro è completato quando grep -c "as unknown as" src/lib/api/*.ts restituisce 0.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Background
The CLI already uses @sentry/api for all API calls (~60+ SDK functions in production). However, 30 as unknown as casts remain in src/lib/api/ — TypeScript bridges between SDK-generated response types and the CLI's internal SentryXxx wrapper types. These casts don't hide real bugs (the runtime shapes match), but they prevent TypeScript from catching future regressions and make the codebase harder to maintain.
This issue tracks the work to get to zero casts and fully adopt the SDK-generated types.
Three categories of work
Category 1 — Response type casts (~20 casts, CLI-only, ~2 days)
Pattern: return data as unknown as SentryTeam[]
The CLI defines SentryTeam = Partial<SdkTeam> & { id, slug, name }. TypeScript can't automatically narrow from the SDK's strict union type to this intersection. At runtime the shapes are identical.
Fix: Make unwrapResult<T> generic so the single cast lives in infrastructure, and all callers are clean:
// infrastructure.ts
export function unwrapResult<T>(result: SdkResult<unknown>, context: string): T {
if (result.error !== undefined) { throwApiError(...) }
return result.data as T; // one cast, all callers clean
}
// teams.ts — before
return data as unknown as SentryTeam[];
// after
return unwrapResult<SentryTeam[]>(result, "Failed to list teams");
Also simplify wrapper types that are already 100% compatible with SDK types:
SentryTeam→ aliasSdkTeamdirectlySentryRelease→ aliasPartial<SdkReleaseResponse>SentryDeploy→ alias SDK type directly
Category 2 — Request body casts (~7 casts, needs backend spec fix)
Pattern: body as unknown as Parameters<typeof sdkFn>[0]["body"]
The SDK marks certain request body fields as required (per the spec), but the CLI passes them as optional and the API silently accepts it. Fixing the spec makes the cast unnecessary.
Backend spec changes needed (getsentry/sentry PRs):
| Endpoint | Field(s) to mark optional |
|---|---|
createANewDashboardForAnOrganization |
widgets |
editAnOrganization_sCustomDashboard |
various fields |
createANewReleaseForAnOrganization |
projects |
updateAnOrganization_sRelease |
various fields |
After each backend fix ships in a new @sentry/api release, the corresponding CLI cast can be removed.
Category 3 — Path parameter casts (3 casts, CLI-only, trivial)
Pattern: dashboard_id: dashboardId as unknown as number
Already blocked on sentry#116836 (dashboard_id type fix). Once that ships:
// Before
dashboard_id: dashboardId as unknown as number,
// After
dashboard_id: dashboardId, // string, as the spec now correctly declares
Wrapper types that need to stay (for now)
Three types keep fields beyond the SDK spec that have never been formally documented:
| Type | Extra fields | Fix |
|---|---|---|
SentryOrganization |
allowMemberProjectCreation, orgRole |
Contribute to Sentry backend spec |
SentryProject |
status (undocumented API field) |
Contribute to Sentry backend spec |
SentryEvent |
dateCreated, fingerprints, sdkUpdates, typed contexts |
Some may be intentionally undocumented; contribute where possible |
Work order
- Phase 1 (CLI-only, ~2 days): Make
unwrapResult<T>generic; drop response-type casts; simplify compatible wrapper types; replacedashboard_idcast withparseInt - Phase 2 (Backend spec, ~3 days + release): Fix dashboard and release request body schemas in getsentry/sentry; bump SDK; remove 7 body casts
- Phase 3 (Ongoing): Contribute undocumented fields to spec; narrow/remove remaining wrapper types as each field lands
Success metric
grep -c "as unknown as" src/lib/api/*.ts # 0
- Lingua principale
- TypeScript
- Stelle
- 123
- Fork
- 14
- Merge medio
- 1g 48m
- PR unite (30g)
- 76
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 getsentry/cli
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 52/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 64/100
I maintainer di solito rispondono entro 1 giorno
-
Evaluate Twinkleplop for terminal code highlightingForse già presa @MathurAditya724 l’ha presa 9 giorni fa. Apertajared
getsentry/cli#1633 · 1 commento · 2 reazioni · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di getsentry/cli
Issue simili
-
Add: CanalPlusSport8SK.skApertacheck:passed streams:add
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
I maintainer di solito rispondono entro 1 giorno
-
[Bug] The shared instance selector's placeholder and no-match text ignore the display languageForse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 90/100
apache/rocketmq-dashboard#5561 ·
I maintainer di solito rispondono entro 3 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
CopilotKit/OpenDots#69 ·
I maintainer di solito rispondono entro 1 giorno
-
sendDefaultPii is reported as deprecated on ReactNativeOptions although dataCollection is hiddenApertaBug React-Native Waiting for: Product Owner
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
getsentry/sentry-react-native#6830 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
OSCI'26
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
GauravKarakoti/SecureFlow#1215 ·
I maintainer di solito rispondono entro 1 giorno