Skip to content

fix(completion): register shell completions for the cloudflare executable #688

Open

Description

@coygeek

Summary of the issue

cloudflare complete emits scripts whose registration and completion callback both target cf. This prevents completions for cloudflare, the executable documented for use when a different cf is already on PATH.

Expected behaviour

The generated script enables tab completion for cloudflare. Completing a cloudflare command calls the Cloudflare CLI even when cf resolves to a different program. The normal cf entry point still supports completion when it resolves to the Cloudflare CLI.

Version of cf used

1.0.0-rc.1

System information and package versions

macOS 27.2 arm64, Node.js 26.13.1, npm 12.2.2, Zsh 5.9, and Bash 5.3.20. The default-branch CI artifact for Zsh was built from the permalinked revision. No account, API calls, or shell profile edits were needed.

Reproduction (optional)

Run these commands in an empty directory with the package installed and both executable names available. The shell processes skip user startup files. Zsh initializes its completion system explicitly.

cloudflare complete zsh > cf-generated.zsh
zsh -f -c 'autoload -Uz compinit; compinit -D; source ./cf-generated.zsh; print -r -- "cf=${_comps[cf]-missing} cloudflare=${_comps[cloudflare]-missing}"'
cloudflare complete bash > cf-generated.bash
bash --noprofile --norc -c 'source ./cf-generated.bash; complete -p cf; complete -p cloudflare'

Relevant error logs (optional)

Zsh prints cf=_cf cloudflare=missing with both the published release and the default-branch CI artifact. Bash finds complete -F __cf_complete cf and reports complete: cloudflare: no completion specification. The Zsh and Bash scripts generate callbacks beginning with cf complete --. The generated Fish and PowerShell scripts also register cf and call cf complete --, as observed by inspecting their output. The Fish and PowerShell scripts were not run.

Evidence

  • Expected source: The Cloudflare CLI installation guide presents cloudflare as the same CLI when another cf is already installed. Its Set up shell completion section documents the complete command.
  • Failure source: The clean Zsh and Bash runs and generated-script inspection described above. The default-branch completion handler passes cf as both arguments to t.setup for every shell.
  • Evidence provenance: observed
  • Local verification: reproduced
  • Reproduction completeness: complete

Restoration check

Run the same shell setup and confirm that cloudflare has a completion handler. With a stub cf earlier on PATH, complete cloudflare wor and observe Cloudflare CLI candidates such as workers without invoking the stub. As a control, verify cf complete zsh continues to work where cf itself is the Cloudflare CLI.

References

Triage assessment

  • Impact level: P2
  • Assessment status: supported
  • Impact basis: The alternate executable loses working shell completion on the tested shells, including in the command-name collision scenario for which it is documented. Normal CLI commands through that executable remain available.
  • Workaround status: available
  • Workaround basis: Editing both the registration and callback command in the generated file gives the alternate command a handler. The edited Bash and Zsh registrations accepted cloudflare, and cloudflare complete -- wor returned the workers candidate with a stub cf on PATH.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions