feat(build): show the Agentkitfile line for each validation error

Aperta
#59 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

@jersonboydmilan ci sta già lavorando.

Dal 18/10/2026.

  • #75 di @jersonboydmilan — aperta

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
57/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
docker, go, yaml

Direzione di ricerca

Start with pkg/agentkit/config/validate.go and pkg/agentkit/config/load.go, then inspect pkg/build/build.go and context.go for how validation errors are wrapped. Add tests for YAML path-to-line lookup and validation using the cases and commands listed in the issue; run go test ./... and make lint. Done means each validation error includes the file and line, Docker can show source snippets, and --call check reports matching locations.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

area/build enhancement help wanted

Problem

When an Agentkitfile has a mistake, the error tells you what is wrong but not where:

validating agentkitfile: tools[1] (fetch): stdio command tools must not set urlEnv, headers, or auth
env[3].name "my-key" must be an env var NAME matching [A-Z0-9_]+; list names only, never values

To find it, you count list items by hand. YAML syntax errors already show the line with a caret (formatYAMLError in pkg/agentkit/config/load.go). The rule checks in validate.go don't.

Docker can show the exact lines of the source file next to an error, as it does for Dockerfiles, but only if the frontend says where the error is. dalec does this for its YAML spec (see dalec's sourcemap.go).

What

Every rule-check error says where in the file it is:

agentkitfile.yaml:14: tools[1] (fetch): stdio command tools must not set urlEnv, headers, or auth
  • Line prefix. Put <file>:<line>: in front of each message. This works everywhere: build output, --call check (#58), CI logs and plain text.
  • Source snippet. Also attach the location to the error the way BuildKit expects, so Docker can show the surrounding lines of the file.
  • Messages stay the same apart from the new prefix.
  • Missing fields. When a field is missing entirely (for example model.name is required), point at its parent (model:). If there's no parent, point at line 1.
  • --call check (#58): its results get the same locations.
Out of scope
  • Changing the wording of any message.
  • Reporting several problems on one line differently.

Why

  • People find and fix mistakes faster, especially in long files with many tools.
  • It works the same way Dockerfile errors already do in Docker and in editors.

How

Where things are
File What it does
pkg/agentkit/config/validate.go Validate() collects problems through add(format, args...) and returns errors.Join(errs...). Most messages already start with a path such as tools[1] (fetch), env[3].name or model.baseURL.
pkg/agentkit/config/load.go Reads the file with github.com/goccy/go-yaml. formatYAMLError already shows lines for syntax errors.
pkg/build/build.go, context.go Build() wraps validation errors. The file name comes from the filename option, default agentkitfile.yaml.
dalec sourcemap.go Example of turning a YAML node into a BuildKit location (nodeToRange, GetErrdefsSource).
Steps
  1. Record where each problem is.
    • Add a variant of add that also takes a YAML path, for example addAt("$.tools[1].urlEnv", format, args...). Store each problem as a small type with Path and Message.
    • Move the common checks to it first: model, tools, env, context providers, expose.
    • Problems without a path can point at line 1 for now. Moving them over can happen step by step.
  2. Find the line.
    • Parse the file into goccy's syntax tree with parser.ParseBytes(data, 0).
    • Turn the path into a node with yaml.PathString(path) and (*yaml.Path).FilterFile(file).
    • node.GetToken().Position gives the line and column.
    • If the path isn't found, try its parent, then its parent's parent, and so on.
    • Put this in a small helper with its own tests.
  3. Attach the location.
    • Add the <file>:<line>: prefix to the message.
    • Also wrap each error with errdefs.WithSource(err, errdefs.Source{...}) from github.com/moby/buildkit/solver/errdefs. Pass the file name, the file contents, Language: "YAML" and the line range. Copy the range conversion from dalec's nodeToRange.
    • Check how docker buildx build displays several errors that each carry a location. If it only shows one snippet, the line prefix still makes every problem easy to find.
  4. --call check (#58). Register the file once with LintResults.AddSource(llb.NewSourceMap(nil, filename, "YAML", data)). Pass each problem's range to AddWarning.
Tests
  • Helper: path-to-line lookup for:
    • nested lists;
    • flow style such as {file: ./prompt.md};
    • instructions as a plain string and as a mapping;
    • missing keys, which should fall back to the parent;
    • a path that doesn't exist at all, which should fall back to line 1.
  • Validation: a fixture with mistakes on known lines. Each error should report the expected line.
  • Build: the error returned by Build() carries a location with the right file name and contents.
  • Update existing tests that compare full messages so they expect the new prefix.

Run:

go test ./...
make lint

Done when

  • Building a broken Agentkitfile prints the file name and line number for every problem, plus a source snippet where Docker shows one.
  • --call check results include the same locations, once #58 lands.
  • Messages are otherwise unchanged.
Lingua principale
Python
Stelle
7
Fork
5
Merge medio
3h 39m
PR unite (30g)
1

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di orka-agents/agentkit

Tutte le issue di orka-agents/agentkit

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.