Skip to content

Export shared IsNotFoundError helper to pkg/errorutil, adopt across pkg/cli and pkg/parser#32757

Merged
pelikhan merged 3 commits into
mainfrom
copilot/export-shared-notfound-error-helper
May 17, 2026
Merged

Export shared IsNotFoundError helper to pkg/errorutil, adopt across pkg/cli and pkg/parser#32757
pelikhan merged 3 commits into
mainfrom
copilot/export-shared-notfound-error-helper

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 17, 2026

Four pkg/cli call 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 unexported isNotFoundError in pkg/parser was the canonical implementation but unreachable from pkg/cli.

Changes

  • New pkg/errorutil package — exports IsNotFoundError(err error) bool: case-insensitive match on "404" or "not found", nil-safe, single source of truth.
// pkg/errorutil/errors.go
func IsNotFoundError(err error) bool {
    if err == nil {
        return false
    }
    msg := strings.ToLower(err.Error())
    return strings.Contains(msg, "404") || strings.Contains(msg, "not found")
}
  • pkg/parser/remote_fetch.go — removes unexported isNotFoundError(errMsg string) bool; both internal call sites updated to errorutil.IsNotFoundError(err).

  • pkg/cli — four sites replaced:

    File Before Fix
    outcome_eval_comment.go Case-sensitive "Not Found" + "404" on err.Error() errorutil.IsNotFoundError(err) — also catches lowercase "not found"
    gateway_logs_mcp.go "not found" only on err.Error() errorutil.IsNotFoundError(err) — now also catches bare "404"
    audit.go 5 separate strings.Contains across both err.Error() and CLI output errorutil.IsNotFoundError(err) for error; output-string checks retained with comment explaining the dual-source need
    logs_download.go Output-only "not found" check errorutil.IsNotFoundError(err) added alongside output check and existing 410 check
  • Parser tests (frontmatter_utils_test.go, import_remote_nested_test.go) updated to call errorutil.IsNotFoundError now that the unexported helper is gone.

Copilot AI and others added 2 commits May 17, 2026 05:25
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
Copilot AI requested a review from pelikhan May 17, 2026 05:28
@pelikhan pelikhan marked this pull request as ready for review May 17, 2026 05:46
Copilot AI review requested due to automatic review settings May 17, 2026 05:46
@pelikhan pelikhan merged commit 6ee52df into main May 17, 2026
@pelikhan pelikhan deleted the copilot/export-shared-notfound-error-helper branch May 17, 2026 05:47
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/errorutil package with nil-safe, case-insensitive IsNotFoundError plus 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.go switches from the now-removed isNotFoundError(string) to errorutil.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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Export and adopt a shared NotFound-error helper across pkg/cli (sergo)

3 participants