Skip to content

Provider errors lose their type between agent and controller; handlers match on error text #499

Description

@retr0h

The agent turns every provider error except provider.ErrUnsupported into a plain string (internal/agent/handler.go:296-315, response.Error = err.Error()). About 30 controller handlers then choose HTTP status codes with strings.Contains(errMsg, "not found").

This has already broken in places:

  • internal/controller/api/node/sysctl/sysctl_update.go:75 returns 500 on any error, so updating a missing key returns 500 instead of the 404 the spec declares, while sysctl_get.go and sysctl_delete.go check for not-found.
  • The not-found branch in internal/controller/api/agent/agent_drain.go:59 and agent_undrain.go:63 can never match, because WriteAgentTimelineEvent never returns such an error.

Fix: add sentinel errors in internal/provider beside ErrUnsupported (for example ErrNotFound), carry an error code in job.Response alongside the message, classify with errors.Is in the agent, and switch on the code in controllers.


Found in the September 2026 codebase review. Tracked in the review tracking issue.

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

    bugSomething isn't workingkind/go

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions