Skip to content

Commit 0e229d9

Browse files
dvdksnclaude
andcommitted
docs(sandboxes): restructure file.parser section
Replace bold pseudo-headings with a synopsis-led structure: a one-line description of the field's purpose and syntax, a properties table, a single prose paragraph for json: path rules, and two focused examples (plain text and nested JSON with env fallback) instead of four. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 3cfcefc commit 0e229d9

1 file changed

Lines changed: 20 additions & 64 deletions

File tree

  • content/manuals/ai/sandboxes/customize

content/manuals/ai/sandboxes/customize/kits.md

Lines changed: 20 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -438,36 +438,25 @@ Service identifiers link credentials to [network rules](#network).
438438

439439
#### file.parser
440440

441-
`file.parser` controls how the proxy extracts a credential value from the file at
442-
`file.path`. Three forms are supported:
441+
`file.parser` tells the proxy how to extract a credential from the file at `file.path`.
442+
Omit it for plain-text files; set it to `json:<dot.path>` to extract a field from a JSON file.
443443

444-
| Parser value | Behavior |
444+
| Value | Behavior |
445445
| ----------------- | ------------------------------------------------------------------------------------ |
446446
| omitted or empty | Reads the entire file as the credential. Leading and trailing whitespace is trimmed. |
447-
| `json:<dot.path>` | Parses the file as JSON and extracts the value at the given dot-separated path. |
448-
| anything else | Rejected with `unsupported parser: <value>`. |
447+
| `json:<dot.path>` | Parses the file as JSON and returns the value at the dot-separated path. |
448+
| any other value | Rejected `unsupported parser: <value>`. |
449449

450-
`json:` is the only supported structured-file format.
450+
For `json:` paths, segments are separated by `.` (for example, `json:credentials.github.token`).
451+
Only object keys can be navigated — arrays are not supported and there is no `[0]`-style indexing.
452+
Keys that contain a literal `.` cannot be referenced. The resolved value must be a string, number,
453+
or boolean; numbers and booleans are converted to strings. Objects, arrays, and null are rejected.
451454

452-
**JSON path rules**
455+
When a source has both `env` and `file` defined, `priority` controls which is tried first. If the
456+
preferred source is unavailable — file missing, field absent, or environment variable unset — the
457+
proxy falls back to the other source automatically.
453458

454-
- Path segments are separated by `.` — for example, `json:credentials.github.token`.
455-
- Only JSON objects can be navigated. Arrays are not supported; there is no `[0]`-style indexing.
456-
- Keys that contain a literal `.` cannot be referenced — the dot is always treated as a separator.
457-
- The value at the resolved path must be a string, number, or boolean. Numbers and booleans are
458-
converted to strings. Objects, arrays, and null are rejected with
459-
`field '<path>' is not a string value`.
460-
461-
**Priority and missing files**
462-
463-
When a source has both `env` and `file`, `priority` controls which is tried first. If the
464-
preferred source is unavailable (environment variable unset, or file missing or inaccessible),
465-
the proxy falls back to the other source automatically. A missing file is not an error on its
466-
own — the source is silently skipped.
467-
468-
**Examples**
469-
470-
Plain-text token file — no parser needed:
459+
Plain-text token file:
471460

472461
```yaml
473462
credentials:
@@ -477,34 +466,18 @@ credentials:
477466
path: "~/.openai/token"
478467
```
479468

480-
Top-level JSON field:
481-
482-
```yaml
483-
credentials:
484-
sources:
485-
anthropic:
486-
file:
487-
path: "~/.claude/settings.json"
488-
parser: "json:primaryApiKey"
489-
```
490-
491-
Given `~/.claude/settings.json`:
492-
493-
```json
494-
{ "primaryApiKey": "sk-ant-...", "secondaryApiKey": "sk-ant-..." }
495-
```
496-
497-
The proxy resolves the credential to the value of `primaryApiKey`.
498-
499-
Nested JSON field:
469+
Nested JSON field, with an environment variable as fallback:
500470

501471
```yaml
502472
credentials:
503473
sources:
504474
github:
475+
env:
476+
- GH_TOKEN
505477
file:
506478
path: "~/.config/myapp/creds.json"
507479
parser: "json:credentials.github.token"
480+
priority: file-first
508481
```
509482

510483
Given `~/.config/myapp/creds.json`:
@@ -517,34 +490,17 @@ Given `~/.config/myapp/creds.json`:
517490
}
518491
```
519492

520-
The proxy resolves the credential to `ghp_xyz`.
521-
522-
File-first with env fallback:
523-
524-
```yaml
525-
credentials:
526-
sources:
527-
anthropic:
528-
env:
529-
- ANTHROPIC_API_KEY
530-
file:
531-
path: "~/.claude/settings.json"
532-
parser: "json:primaryApiKey"
533-
priority: file-first
534-
```
535-
536-
Tries the JSON file first; falls back to the environment variable if the file is
537-
missing or the field is absent.
493+
The proxy resolves the credential to `ghp_xyz`, falling back to `GH_TOKEN` if the file is
494+
missing or the path doesn't resolve.
538495

539-
**Common errors**
496+
Common errors when using `json:` parsers:
540497

541498
| Error message | Cause |
542499
| --------------------------------------------- | ------------------------------------------------------------------- |
543500
| `field 'X' not found in JSON` | The path doesn't exist in the file. |
544501
| `cannot navigate to field 'X': not an object` | A path segment hit a string, array, or scalar instead of an object. |
545502
| `field 'X' is not a string value` | The resolved value is an object, array, or null. |
546503
| `failed to parse JSON: ...` | The file is not valid JSON. |
547-
| `unsupported parser: <value>` | The parser string doesn't start with `json:` and isn't empty. |
548504

549505
### Network
550506

0 commit comments

Comments
 (0)