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

オープン
#4,918 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
graphql, typescript

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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

主要言語
TypeScript
スター
30
フォーク
10
平均マージ
2日 12時間
マージ済み PR(30日)
276

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

Urigo/accounter-fullstack のほかの issue

Urigo/accounter-fullstack の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。