argo-cd: Wrap error objects to include context
Summary
There are a lot of places in source where we return err
without adding context with fmt.Errorf()
.
Motivation
Error messages without wrapping context are difficult to debug.
Proposal
Find places where we return unwrapped errors and add context.
Example:
// old code
err := c.cache.GetItem()
if err != nil {
return err
}
// new code
err := c.cache.GetItem()
if err != nil {
return fmt.Errorf("error getting item from the cache: %w", err)
}
This is a top-level issue and probably won’t be solved with any single PR.
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 2
- Comments: 15 (4 by maintainers)
Commits related to this issue
- chore: wrap error objects to include context (#10592) (#10859) * Wrap error objects to include context Signed-off-by: Nir Shtein <89006520+nirsht@users.noreply.github.com> * Fix CR Signed-of... — committed to argoproj/argo-cd by nirsht 2 years ago
- chore: wrap error objects to include context (#10592) (#10871) * chore: wrap error objects to include context Signed-off-by: Aiman Fatima <aimanfatimadl@gmail.com> * chore: review comments S... — committed to argoproj/argo-cd by aimanfatima 2 years ago
- Wrap error objects to include context #10592 — committed to nsahai8/argo-cd by deleted user 2 years ago
- wrap error objects to include context (#10592) Signed-off-by: Niharika <ns8gupta@gmail.com> — committed to nsahai8/argo-cd by deleted user 2 years ago
- chore: wrap error objects to include context (#10592) #10905 Signed-off-by: Niharika <ns8gupta@gmail.com> Signed-off-by: Niharika <niharika_sahai@intuit.com> — committed to nsahai8/argo-cd by nsahai8 2 years ago
- chore: wrap error objects to include context (#10592) (#10940) Signed-off-by: Niharika <ns8gupta@gmail.com> Signed-off-by: Niharika <niharika_sahai@intuit.com> Signed-off-by: Niharika <ns8gupta@g... — committed to argoproj/argo-cd by nsahai8 2 years ago
- wrap error objects to include context (#10592) Signed-off-by: ChandanChainani <chainanichan@gmail.com> — committed to ChandanChainani/argo-cd by ChandanChainani 2 years ago
- chore: improve error logs (#10944) * fix: Resource list loading slowly due to Sync Wave sorting (#10932) Signed-off-by: Alexander Matyushentsev <AMatyushentsev@gmail.com> Signed-off-by: Smriti Pr... — committed to argoproj/argo-cd by smriti0710 2 years ago
- chore: wrap error objects to include context (#10592) (#10940) Signed-off-by: Niharika <ns8gupta@gmail.com> Signed-off-by: Niharika <niharika_sahai@intuit.com> Signed-off-by: Niharika <ns8gupta@gmai... — committed to nbjohnson/argo-cd by nsahai8 2 years ago
- chore: improve error logs (#10944) * fix: Resource list loading slowly due to Sync Wave sorting (#10932) Signed-off-by: Alexander Matyushentsev <AMatyushentsev@gmail.com> Signed-off-by: Smriti Praka... — committed to nbjohnson/argo-cd by smriti0710 2 years ago
- chore: updated error message to include context (#10592) (#10960) * Updated error message Signed-off-by: Jennifer Trevilian <JCPTrevillian@Gmail.com> * Updated error message Signed-off-by: J... — committed to argoproj/argo-cd by JCPTrevillian 2 years ago
- chore: wrap errors with message (#10592) (#10986) * issue-10592 Wrap errors with message Signed-off-by: Apoorva Mahabaleshwara <apoorvamahabaleshwara@Apoorvas-MBP.attlocal.net> Signed-off-by: Apo... — committed to argoproj/argo-cd by apoorvam1 2 years ago
- chore: wrap errors with message (#10592) (#10986) * issue-10592 Wrap errors with message Signed-off-by: Apoorva Mahabaleshwara <apoorvamahabaleshwara@Apoorvas-MBP.attlocal.net> Signed-off-by: Apoorv... — committed to nsinghal12/argo-cd by apoorvam1 2 years ago
- chore: wrap errors with message (#10592) (#10986) * issue-10592 Wrap errors with message Signed-off-by: Apoorva Mahabaleshwara <apoorvamahabaleshwara@Apoorvas-MBP.attlocal.net> Signed-off-by: Apoorv... — committed to emirot/argo-cd by apoorvam1 2 years ago
- test: simplify bcrypt test (#11013) * chore: wrap errors with message (#10592) (#10986) * issue-10592 Wrap errors with message Signed-off-by: Apoorva Mahabaleshwara <apoorvamahabaleshwara@Apoor... — committed to argoproj/argo-cd by emirot 2 years ago
@nirsht that’s precisely the sort of PR we need! I might nitpick some of the messages, but this is a huge step in the right direction. 😃
fixed a few more of these https://github.com/argoproj/argo-cd/pull/15019 @crenshaw-dev
Hey @crenshaw-dev , is this something along the lines of what you’re expecting for this issue? https://github.com/argoproj/argo-cd/pull/14851 If so, I can start working on fixing it in more places.
To be clear, there are hundreds, if not thousands of places in our code base that return unwrapped errors which should be wrapped. PRs are welcome whether they’re for one or for a hundred. No need to coordinate, it’s extremely unlikely that two people will submit the same changes. 😃