Export shared IsNotFoundError helper to pkg/errorutil, adopt across pkg/cli and pkg/parser#32757
Merged
Merged
Conversation
4 tasks
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
…ogs_download Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Export and adopt shared NotFound-error helper across pkg/cli
Export shared IsNotFoundError helper to pkg/errorutil, adopt across pkg/cli and pkg/parser
May 17, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Introduces a new pkg/errorutil package exporting a shared IsNotFoundError(err error) bool helper to consolidate four divergent inline implementations of 404/not-found detection across pkg/cli, and replaces the unexported isNotFoundError in pkg/parser (which was the canonical implementation but unreachable outside the package).
Changes:
- New
pkg/errorutilpackage with nil-safe, case-insensitiveIsNotFoundErrorplus tests. - Four call sites in
pkg/cli(outcome_eval_comment.go,gateway_logs_mcp.go,audit.go,logs_download.go) migrated to use the shared helper, fixing inconsistencies (case-sensitivity, missing bare"404"matches). pkg/parser/remote_fetch.goswitches from the now-removedisNotFoundError(string)toerrorutil.IsNotFoundError(err); parser tests updated accordingly.
Show a summary per file
| File | Description |
|---|---|
| pkg/errorutil/errors.go | New shared helper with documentation. |
| pkg/errorutil/errors_test.go | Tests covering nil, various 404 forms, and non-matching errors. |
| pkg/parser/remote_fetch.go | Removes unexported helper; both call sites use shared helper. |
| pkg/parser/import_remote_nested_test.go | Tests updated to pass error values instead of strings. |
| pkg/parser/frontmatter_utils_test.go | Same migration; also fixes a stale comment that referred to an unrelated test. |
| pkg/cli/outcome_eval_comment.go | Replaces case-sensitive inline check; also catches lowercase "not found". |
| pkg/cli/gateway_logs_mcp.go | Replaces "not found"-only check; now also catches bare "404". |
| pkg/cli/audit.go | Replaces err.Error() 404 check with shared helper; output string checks retained with comment. |
| pkg/cli/logs_download.go | Adds shared-helper check alongside existing output and 410 checks. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 9/9 changed files
- Comments generated: 0
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Four
pkg/clicall sites each reimplemented 404/not-found detection inline with different subsets of signals — one was case-sensitive (outcome_eval_comment.go), one skipped bare"404"(gateway_logs_mcp.go), and one mixed in 410 detection without covering all 404 forms. The unexportedisNotFoundErrorinpkg/parserwas the canonical implementation but unreachable frompkg/cli.Changes
pkg/errorutilpackage — exportsIsNotFoundError(err error) bool: case-insensitive match on"404"or"not found", nil-safe, single source of truth.pkg/parser/remote_fetch.go— removes unexportedisNotFoundError(errMsg string) bool; both internal call sites updated toerrorutil.IsNotFoundError(err).pkg/cli— four sites replaced:outcome_eval_comment.go"Not Found"+"404"onerr.Error()errorutil.IsNotFoundError(err)— also catches lowercase "not found"gateway_logs_mcp.go"not found"only onerr.Error()errorutil.IsNotFoundError(err)— now also catches bare"404"audit.gostrings.Containsacross botherr.Error()and CLI outputerrorutil.IsNotFoundError(err)for error; output-string checks retained with comment explaining the dual-source needlogs_download.go"not found"checkerrorutil.IsNotFoundError(err)added alongside output check and existing 410 checkParser tests (
frontmatter_utils_test.go,import_remote_nested_test.go) updated to callerrorutil.IsNotFoundErrornow that the unexported helper is gone.