juanfont/headscale · error

compiling SSH policy: %w

Error message

compiling SSH policy: %w

What it means

Error "compiling SSH policy: %w" thrown in juanfont/headscale.

Source

Thrown at hscontrol/policy/v2/policy.go:438

	return false
}

// SSHPolicy returns the [tailcfg.SSHPolicy] for node, compiling and
// caching on first access. Rules use SessionDuration = 0 (no
// auto-approval) and emit check URLs of the form
// /machine/ssh/action/{src}/to/{dst}?local_user={local_user} per the
// SaaS wire format. Cache is invalidated on policy reload.
func (pm *PolicyManager) SSHPolicy(baseURL string, node types.NodeView) (*tailcfg.SSHPolicy, error) {
	pm.mu.RLock()
	defer pm.mu.RUnlock()

	if sshPol, ok := pm.sshPolicyMap.Load(node.ID()); ok {
		return sshPol, nil
	}

	sshPol, err := pm.pol.compileSSHPolicy(baseURL, pm.users, node, pm.nodes)
	if err != nil {
		return nil, fmt.Errorf("compiling SSH policy: %w", err)
	}

	pm.sshPolicyMap.Store(node.ID(), sshPol)

	return sshPol, nil
}

// SSHCheckParams resolves the SSH check period for a source-destination
// node pair by looking up the current policy. This avoids trusting URL
// parameters that a client could tamper with. First-match wins across
// the policy's SSH rules.
//
// Returns (duration, true) when a matching rule is found and
// (0, false) when none is. A (0, true) return means the matched rule
// uses a zero check period (re-check every session).
func (pm *PolicyManager) SSHCheckParams(
	srcNodeID, dstNodeID types.NodeID,
) (time.Duration, bool) {

View on GitHub (pinned to 565fd254d0)

Solutions

  1. Inspect the wrapped error for the underlying cause and correct the failing condition (compiling SSH policy); retry the operation after fixing the input, configuration, or environment.

Example fix

Inspect the wrapped error for the underlying cause and correct the failing condition (compiling SSH policy); retry the operation after fixing the input, configuration, or environment.

When it happens

Trigger: Thrown at hscontrol/policy/v2/policy.go:438 when the library encounters an invalid state.

Common situations: Compilation of the SSH section of the policy failed. Review the SSH rules for invalid actions, sources, or destinations.


AI-assisted analysis of juanfont/headscale@565fd254d0 (2026-08-15). Data as JSON: /api/errors/d908210a8b635e52. Report an issue: GitHub.