Repository navigation
[repository-quality] Repository Quality: Error-Handling Contract Consistency #65861
Closed
Replies: 1 comment
|
This discussion has been marked as outdated by Repository Quality Improvement Agent. A newer discussion is available at Discussion #66149. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
🎯 Repository Quality Improvement Report - Error Handling Contract Consistency
Analysis Date: 2026-10-05
Focus Area: Error-handling contract consistency (wrapping, sentinels, string matching, actionable messages)
Strategy Type: Custom
Custom Area: Yes — the repo has many custom error linters (
errorfwrapv,errstringmatch,errormessage,fmterrorfnoverbs), so the question is where the conventions still leak.Executive Summary
Error handling is largely disciplined: about 1,900 of roughly 3,180
fmt.Errorfcalls in non-test code wrap with%w. No production%v-with-error formatting was found. No trailing punctuation was found either. Only 29 messages start with a capital letter, and the ones sampled were mostly acronyms such as GitHub, URL and API.The gaps are structural. There are zero exported sentinel errors (
Err... = errors.New) across about 750errors.Newcalls, even thougherrors.Is/Asis used 172 times. Callers therefore have no stable values to match on.pkg/cli/update_extension_check.go:439still matches onerr.Error()text. Some static messages (mcp_add.go:253,261,secrets.go:40) state a failure without saying what to do.Full Analysis Report
Focus Area: Error-handling contract consistency
Current State Assessment
fmt.Errorf(non-test)%wwrappingerrors.New(non-test)errors.Is/Asusesstrings.Contains(err.Error(), ...)in productionupdate_extension_check.go:439)%vwith errFindings
Strengths
%v.Areas for Improvement
errors.Newsites cannot match on stable values.update_extension_check.go.pkg/cli/mcp_add.go:253,261andpkg/cli/secrets.go:40.frontmatter_content.go:231, which starts with a function name;model_aliases.go:57).fmt.Errorfcalls don't wrap. Many are legitimate leaf errors, but they were not audited.🤖 Tasks for Copilot Agent
NOTE TO PLANNER AGENT: Split the following tasks into individual work items.
Improvement Tasks
Task 1: Replace error-text matching with typed/sentinel checks
Priority: High
Estimated Effort: Small
Focus Area: Error handling
Description:
update_extension_check.gousesstrings.Contains(err.Error(), msg). Replace it witherrors.Is/errors.As, or with a sentinel error.Acceptance Criteria:
strings.Contains(err.Error()remains in the production code ofpkg/cliCode Region:
pkg/cli/update_extension_check.goTask 2: Introduce sentinel errors for common failure classes
Priority: Medium
Estimated Effort: Medium
Focus Area: Error handling
Description: Find repeated
errors.Newmessages (not-found, unsupported, auth, rate limit) and promote them to exported sentinels. Wrap them with%wso callers can useerrors.Is.Acceptance Criteria:
errors.Iswhere they previously compared stringsCode Region:
pkg/cli,pkg/workflow,pkg/parserRun a duplicate-message analysis of errors.New and fmt.Errorf literals in pkg/. Introduce Err* sentinels for the top repeated failure classes. Wrap them with %w, and update the callers and tests.Task 3: Make terse errors actionable
Priority: Medium
Estimated Effort: Small
Focus Area: Usability
Description: Add expected/required/example details to the terse messages in
pkg/cli/mcp_add.go(lines 253 and 261) andpkg/cli/secrets.go:40. Fix the capitalization offrontmatter_content.go:231andmodel_aliases.go:57.Acceptance Criteria:
Code Region:
pkg/cli/mcp_add.go,pkg/cli/secrets.go,pkg/parser/frontmatter_content.go,pkg/workflow/model_aliases.goTask 4: Audit unwrapped fmt.Errorf calls that take an error argument
Priority: Low
Estimated Effort: Medium
Focus Area: Code quality
Description: About 40% of
fmt.Errorfcalls don't use%w. Identify those that pass an error through another verb or drop it. A prior grep found none using%v, so check%sand.Error()concatenation. Then wrap them.Acceptance Criteria:
errorfwrapvlinter is extended if needed to catch%s/.Error()usageCode Region:
pkg/,pkg/linters/errorfwrapv📊 Historical Context
Previous Focus Areas
🎯 Recommendations
Immediate Actions (This Week)
Short-term Actions (This Month)
Long-term Actions (This Quarter)
📈 Success Metrics
Next Steps
Generated by Repository Quality Improvement Agent
Next analysis: 2026-10-06 — Focus area selected by diversity algorithm
All reactions