Skip to content

connection add: optional org prompt blocks non-interactive mode when --plugin flag is set #147

@ewega

Description

@ewega

Description

gh devlake configure connection add --plugin github --token <PAT> --name "My Connection" still prompts interactively for "Organization slug (optional, press Enter to skip)" even though all required flags are provided and the github plugin has NeedsOrg: false.

This prevents fully non-interactive/scripted usage of connection creation for the github plugin.

Steps to Reproduce

  1. Have a DevLake instance running (gh devlake deploy local)
  2. Run:
    gh devlake configure connection add --plugin github --token ghp_xxx --name "GitHub"
  3. The CLI prompts:
    Organization slug (optional, press Enter to skip):
    
    ...and blocks waiting for input.

Expected Behavior

When --plugin and --token flags are provided, and the plugin does not require an org (NeedsOrg: false), the command should skip the org prompt entirely and create the connection non-interactively.

Actual Behavior

The org prompt appears regardless, blocking automation scripts like setup-demo.ps1 from running unattended.

Impact

This affects any scripted/automated setup that uses gh devlake configure connection add for plugins where org is optional (e.g., github, gitlab, circleci). The gh-copilot plugin works correctly since --org is passed explicitly and NeedsOrgOrEnt: true.

Workaround

Use the DevLake REST API directly instead of the CLI for connection creation:

Invoke-RestMethod -Uri "http://localhost:8080/plugins/github/connections" -Method POST -ContentType "application/json" -Body (@{
    name = "GitHub"; endpoint = "https://api.github.com/"; authMethod = "AccessToken"
    token = "ghp_xxx"; enableGraphql = $true; rateLimitPerHour = 4500
} | ConvertTo-Json)

Suggested Fix

In cmd/configure_connection_add.go, when running in flag mode (i.e., --plugin is set), skip the org/enterprise prompts for plugins where NeedsOrg, NeedsEnterprise, and NeedsOrgOrEnt are all false.

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