Skip to content

Name an http:// server and the server's 401 reason in the log - #48

Merged
mastacontrola merged 1 commit into
mainfrom
fix/name-http-and-refusal-reason
Nov 17, 2026
Merged

mastacontrola merged 1 commit into
mainfrom
fix/name-http-and-refusal-reason

Conversation

@mastacontrola

Copy link
Copy Markdown
Member

Problem

Forum topic 18320. An agent pointed at an http:// FOG server logged two lines that named no cause:

  • directory rejoin: could not ask the server which features it offers ... Check that the server is reachable. The check sends nothing to a non-https address, so reachability was never the issue.
  • server refused this certificate (Ns); keeping it and retrying, forever. The server sent a reason with the 401 (no_client_certificate), and the agent dropped it.

Change

  • internal/enroll/directory_features.go: a non-https address returns the new ErrDirectoryFeaturesNeedHTTPS. cmd/fog-agent/directory_rejoin.go logs the configured address as the cause and leaves directory rejoin off, with no retry.
  • internal/enroll/client.go: a 401 with a reason returns a refusedError that errors.Is matches to ErrUnauthorized only. UnauthorizedReason() reads it. The reason is kept only if it matches ^[a-z_]{1,64}$. unknown_certificate is unchanged.
  • cmd/fog-agent/facts.go, main.go: both refusal lines print the reason and what to check.
  • docs/design/protocol-v1.md: the poll and renew 401 rows split by reason. The feature-check paragraph covers the non-https case and the retry of an unavailable server.

Verified

  • New tests in cmd/fog-agent and internal/enroll. Each one fails with the old behavior put back and passes with the fix.
  • The CI command set passes locally: gofmt -l ., go vet (linux, windows, darwin), go test ./... -count=1, and the build.
  • Reviewed by spec-reviewer (opus) and standards-reviewer (sonnet). Round 2: spec CLEAN; one standards finding (the renew 401 row), fixed.

🤖 Generated with Claude Code

Forum topic 18320: an agent pointed at an http:// server logged "could
not ask the server which features it offers ... Check that the server
is reachable", then "server refused this certificate" forever. Neither
line named the cause.

- The directory feature check sends nothing to a non-https address.
  The agent now says the address is not https:// and leaves directory
  rejoin off without retrying, instead of blaming reachability.
- A 401 carries the server's reason. The refusal lines now print it
  (no_client_certificate, server_error, ambiguous_certificate) with what
  to check. The reason is logged only if it matches [a-z_]{1,64}.
  unknown_certificate keeps its own sentinel and behavior.
- protocol-v1.md: the 401 rows now split by reason, and the feature
  check paragraph covers the non-https case and the retry.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mastacontrola
mastacontrola merged commit 0785c8f into main Nov 17, 2026
2 checks passed
@mastacontrola
mastacontrola deleted the fix/name-http-and-refusal-reason branch November 17, 2026 12:45
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.

1 participant