Skip to content

fix: clearer error when binary name used as pattern fallback - #2173

Open
OdinKral wants to merge 2 commits into
danielmiessler:mainfrom
OdinKral:fix/missing-pattern-error-message
Open

fix: clearer error when binary name used as pattern fallback#2173
OdinKral wants to merge 2 commits into
danielmiessler:mainfrom
OdinKral:fix/missing-pattern-error-message

Conversation

@OdinKral

Copy link
Copy Markdown

Replaces #2117 — same commits, resubmitted from a personal fork.

On #2123 you were unable to push maintainer fixes to my branch:

ERROR: Permission to AnsibleBBridge/Fabric.git denied to ksylvan.

That fork is owned by an organization, and GitHub's "allow edits by maintainers" grant only works for personally-owned forks — the API still reports maintainerCanModify: true, so there was no signal from my side that anything was wrong. All of my open PRs were on that fork and had the same problem, so I've moved them to OdinKral/fabric-contrib, which is a personal fork. You should be able to push to these.

Also rebased onto current main. #2117 had gone CONFLICTING because #2167 added pattern_invalid_name to the locale files this PR also touches; both keys are kept. go build ./internal/cli/ passes and the added TestPatternFromBinaryName passes all 6 subtests. (Note TestBuildChatOptionsWithImageParameters fails, but it fails identically on a clean upstream/main — pre-existing, unrelated to this PR.)


Problem

Closes #2112.

When fabric is invoked via a symlink or renamed binary (e.g. fabric-ai) without -p, the binary name is silently used as the pattern name. If that pattern doesn't exist, the user sees:

could not get pattern fabric-ai: pattern 'fabric-ai' not found. Run 'fabric -l' to see available patterns

There is no hint that the binary name was used as the fallback, so the user doesn't know to add -p.

Fix

Adds a patternFromBinaryName() helper in flags.go that checks whether the current pattern matches the binary-name fallback condition (mirrors the existing fallback logic). When handleChatProcessing returns an error and this condition is true, the error is wrapped with a hint:

Hint: no -p flag was given; binary name 'fabric-ai' was used as the pattern name. Use -p <pattern> to specify a pattern explicitly.

The symlink use-case (intentionally naming a binary after a pattern) is not broken — it still works the same way; the hint only appears when the pattern lookup fails.

Changes

  • internal/cli/flags.go — add patternFromBinaryName() helper
  • internal/cli/cli.go — wrap chat error with hint when binary-name fallback is the likely cause
  • internal/i18n/locales/en.json — add pattern_from_binary_name_hint i18n key
  • internal/cli/flags_test.go — 6 unit tests for patternFromBinaryName()

Test plan

  • Run go test ./internal/cli/... — new TestPatternFromBinaryName tests pass
  • Symlink fabric to fabric-ai, run echo "hi" | fabric-ai without patterns installed — verify new hint appears in error output
  • Run with -p summarize as normal — verify no change in behavior

OdinKral and others added 2 commits July 29, 2026 08:45
When fabric is invoked via a symlink or renamed binary (e.g. fabric-ai)
without -p, the binary name was silently used as the pattern. If that
pattern doesn't exist the user saw a confusing 'pattern not found' error
with no indication that they forgot to specify -p.

Adds patternFromBinaryName() helper and augments the chat error with a
hint explaining that the binary name was used as the fallback pattern
and how to specify one explicitly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds the English placeholder text for the hint added in the previous
commit to all 10 non-English locale files so the key is present for
translators and the i18n bundle is consistent.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

[Bug]: Misleading "pattern '<binary-name>' not found" when no pattern is specified, plus README zsh yt() example is broken since #1960

1 participant