hashicorp/packer · error

Invalid github.com URI %q: a Github-compatible source must b

Error message

Invalid github.com URI %q: a Github-compatible source must be in the github.com/<namespace>/<name> format.

What it means

NewGithubPlugin validates a plugin source address and requires it to resolve to exactly three parts (github.com/<namespace>/<name>). This error is returned when the address splits into a different number of components, so it is not a well-formed Github-compatible source URI.

Source

Thrown at packer/plugin-getter/github/getter.go:181

}

func (t *HostSpecificTokenAuthTransport) base() http.RoundTripper {
	if t.Base != nil {
		return t.Base
	}
	return http.DefaultTransport
}

type GithubPlugin struct {
	Hostname  string
	Namespace string
	Type      string
}

func NewGithubPlugin(source *addrs.Plugin) (*GithubPlugin, error) {
	parts := source.Parts()
	if len(parts) != 3 {
		return nil, fmt.Errorf("Invalid github.com URI %q: a Github-compatible source must be in the github.com/<namespace>/<name> format.", source.String())
	}

	if parts[0] != defaultHostname {
		return nil, fmt.Errorf("%q doesn't appear to be a valid %q source address; check source and try again.", source.String(), defaultHostname)
	}

	return &GithubPlugin{
		Hostname:  parts[0],
		Namespace: parts[1],
		Type:      strings.Replace(parts[2], "packer-plugin-", "", 1),
	}, nil
}

func (gp GithubPlugin) RealRelativePath() string {
	return path.Join(
		gp.Namespace,
		fmt.Sprintf("packer-plugin-%s", gp.Type),
	)

View on GitHub (pinned to eb36e3c3e4)

Solutions

  1. Write the source as github.com/<namespace>/<name> with exactly three slash-separated parts.
  2. Remove extra path segments (versions, subfolders) from the source; pin versions via version constraints instead.
  3. Use full protocol-prefixed sources (e.g. packer-plugin-... paths or other protocols) when not targeting github.com.
  4. Run `packer init` and read the error's %q value to see the exact malformed address.

Example fix

// before
required_plugins {
  amazon = {
    source = "github.com/hashicorp"
  }
}

// after
required_plugins {
  amazon = {
    source  = "github.com/hashicorp/amazon"
    version = ">= 1.0.0"
  }
}
Defensive patterns

Strategy: validation

Validate before calling

parts := strings.Split(strings.Trim(source, "/"), "/")
if len(parts) != 3 || parts[0] != "github.com" {
    return fmt.Errorf("source %q must be github.com/<namespace>/<name>", source)
}

Try / catch

if err := initPlugins(); err != nil {
    if strings.Contains(err.Error(), "Invalid github.com URI") { /* fix required_plugins source */ }
}

Prevention

When it happens

Trigger: Calling Get with a required_plugins source like "github.com/hashicorp" (missing name), "github.com/hashicorp/name/extra" (too many parts), or any address whose Parts() does not yield exactly 3 elements.

Common situations: Copy-pasting a partial plugin path in required_plugins; including a version or subpath in the source string; forgetting that github.com sources must be namespace/name only (no tag/refs).

Related errors


AI-assisted analysis of hashicorp/packer@eb36e3c3e4 (2026-09-05). Data as JSON: /api/errors/0ba30dd1236ace48. Report an issue: GitHub.