Skip to content

Comments

fix: Fish completion script corrupted by INFO log message#259

Merged
kezhenxu94 merged 2 commits intoapache:mainfrom
jhult:fix/completion-script
Feb 11, 2026
Merged

fix: Fish completion script corrupted by INFO log message#259
kezhenxu94 merged 2 commits intoapache:mainfrom
jhult:fix/completion-script

Conversation

@jhult
Copy link
Contributor

@jhult jhult commented Feb 11, 2026

Bug

Fish completion script has an INFO log message at the start of the file, which breaks the shell script syntax:

INFO Loading configuration from file: .licenserc.yaml
# fish completion for license-eye...

This causes fish to error: 'end' outside of a block when sourcing the completion file. Example:

❯ license-eye header /opt/homebrew/share/fish/vendor_completions.d/license-eye.fish (line 39): 'end' outside of a block
    end
    ^~^
from sourcing file /opt/homebrew/share/fish/vendor_completions.d/license-eye.fish
source: Error while reading file ['/opt/homebrew/share/fish/vendor_completions.d/license-eye.fish'](url)

Root Cause

The PersistentPreRunE hook in commands/root.go loads the config file, which logs an INFO message before the completion script is generated. When running license-eye completion fish, the config loading happens before outputting the completion script.

The issue manifests in two ways:

  1. When generating the completion file directly
  2. During actual completion when cobra internally calls __complete command

Fix

Skip config loading in PersistentPreRunE for both:

  • The completion parent command
  • The __complete command used internally by cobra

@wu-sheng wu-sheng requested review from Copilot and kezhenxu94 and removed request for Copilot February 11, 2026 11:50
@kezhenxu94 kezhenxu94 merged commit 8d544cd into apache:main Feb 11, 2026
1 check passed
@jhult jhult deleted the fix/completion-script branch February 11, 2026 16:57
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.

2 participants