Validate explanation pointers before loading configuration

This commit is contained in:
2026-11-18 00:29:56 +00:00
parent 347ef05b41
commit 0663fe566a
3 changed files with 26 additions and 6 deletions

View File

@@ -75,6 +75,11 @@ func runConfigExplain(args []string, stdout, stderr io.Writer, opts Options) int
return 2
}
pointer := fs.Arg(0)
parsed, err := configkit.ParsePath(pointer)
if err != nil || parsed.String() != pointer {
fmt.Fprintf(stderr, "notarius: %q is not a canonical JSON Pointer\n", pointer)
return 2
}
if *scope == "promptkit" {
loaded, _, err := loadConfigKit(*configPath, *overlay, nil, opts)
if err != nil {
@@ -101,11 +106,6 @@ func runConfigExplain(args []string, stdout, stderr io.Writer, opts Options) int
}
return 0
}
parsed, err := configkit.ParsePath(pointer)
if err != nil || parsed.String() != pointer {
fmt.Fprintf(stderr, "notarius: %q is not a canonical JSON Pointer\n", pointer)
return 2
}
loaded, _, err := loadConfigKit(*configPath, *overlay, nil, opts)
if err != nil {
writeConfigLoadError(stderr, err)