Resolvers return CommonError after side effects, so the client can't tell whether a failed mutation ran

Abierto
#4,918 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 2 días

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
35/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
graphql, typescript

Línea de trabajo

Start by reading the listed resolver and OCR helper files, then inspect packages/client/src/helpers/mutation-dedupe.ts and the hooks using useApiMutation. Trace each listed mutation from its side effects through error handling, and review the related issues #4896 and #4907 for client behavior. Done means the listed mutations communicate reliably whether side effects ran and safe client hooks opt into liftOnCommonError.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Many mutation resolvers wrap their whole body in try { … } catch { return { __typename: 'CommonError', … } }. The catch also covers failures that happen after an irreversible side effect. Examples:

  • uploadDocument (modules/documents/resolvers/documents.resolver.ts): uploads to Cloudinary in getDocumentFromFile, then inserts. If the insert fails, the result is a CommonError and the file is already uploaded.
  • insertNewBusiness (modules/financial-entities/resolvers/businesses.resolver.ts): inserts the financial entity, then the business.
  • closeDocument (modules/documents/resolvers/documents.resolver.ts): calls Green Invoice, then updates the DB.
  • reprocessDocumentOcr / batchReprocessDocumentsOcr (modules/documents/helpers/reprocess-ocr.helper.ts): a failure after the paid OCR call (e.g. in fillDocumentFromOcr) is reported as a CommonError.

Why it matters: the client's duplicate-mutation guard (packages/client/src/helpers/mutation-dedupe.ts, the dedupe option of useApiMutation, added in Urigo/accounter-fullstack#4896 and Urigo/accounter-fullstack#4907) would let the user retry straight away after a clean failure. Because a CommonError might mean "partly done", the guard now always keeps its 20-second window. The opt-in dedupe.liftOnCommonError exists, but no mutation can safely use it yet.

Possible directions:

  • Return CommonError only for failures before any side effect (validation, not found), and let later failures surface as GraphQL errors.
  • Or add a field to CommonError (e.g. sideEffectsApplied: Boolean).
  • Or make the side-effecting steps compensate or roll back.

Done when: the mutations above report "nothing ran" in a way the client can trust, and the matching client hooks opt into liftOnCommonError where it's safe.


Generated by Claude Code

Lenguaje dominante
TypeScript
Estrellas
30
Forks
10
Merge medio
2 d 12 h
PR fusionados (30 d)
276

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de Urigo/accounter-fullstack

Todos los issues de Urigo/accounter-fullstack

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.