feat(build): show the Agentkitfile line for each validation error
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
- Ambito
- backend, build-system
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
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
- Record where each problem is.
- Add a variant of
addthat also takes a YAML path, for exampleaddAt("$.tools[1].urlEnv", format, args...). Store each problem as a small type withPathandMessage. - 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.
- Add a variant of
- 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().Positiongives 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.
- Parse the file into goccy's syntax tree with
- Attach the location.
- Add the
<file>:<line>:prefix to the message. - Also wrap each error with
errdefs.WithSource(err, errdefs.Source{...})fromgithub.com/moby/buildkit/solver/errdefs. Pass the file name, the file contents,Language: "YAML"and the line range. Copy the range conversion from dalec'snodeToRange. - Check how
docker buildx builddisplays several errors that each carry a location. If it only shows one snippet, the line prefix still makes every problem easy to find.
- Add the
--call check(#58). Register the file once withLintResults.AddSource(llb.NewSourceMap(nil, filename, "YAML", data)). Pass each problem's range toAddWarning.
Tests
- Helper: path-to-line lookup for:
- nested lists;
- flow style such as
{file: ./prompt.md}; instructionsas 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 checkresults 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
- Include un Dockerfile o un file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di orka-agents/agentkit
-
fix(pydantic-ai): CI fails with newest pydantic-ai (unexpected 'history' argument)Forse già presa @gambtho l’ha presa 30 giorni fa. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
orka-agents/agentkit#77 ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
orka-agents/agentkit#76 · 3 commenti ·
-
area/build area/orka area/runtime blocked enhancement
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
orka-agents/agentkit#69 ·
-
area/build area/orka area/runtime enhancement
Difficoltà 4/5 3-5 giorni Idoneità per principianti 68/100
orka-agents/agentkit#68 ·
-
area/build enhancement testing
Difficoltà 5/5 Più di una settimana Idoneità per principianti 42/100
orka-agents/agentkit#65 ·
Tutte le issue di orka-agents/agentkit
Issue simili
-
【文档错误】创建镜像空间步骤中的截图标注与文字描述不一致Apertaenhancement
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 62/100
DaoCloud/DaoCloud-docs#7839 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 78/100
sav-oss-org/ptusa_main#1610 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
I maintainer di solito rispondono entro 1 giorno
-
bug status/accepted type/bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
microsoft/apm#4925 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
sagemathinc/sagebrush#1701 ·
I maintainer di solito rispondono entro 1 giorno