@@ -513,36 +513,25 @@ Service identifiers link credentials to [network rules](#network).
513513
514514# ### file.parser
515515
516- ` file.parser` controls how the proxy extracts a credential value from the file at
517- `file .path`. Three forms are supported :
516+ ` file.parser` tells the proxy how to extract a credential from the file at `file.path`.
517+ Omit it for plain-text files; set it to `json:<dot .path>` to extract a field from a JSON file.
518518
519- | Parser value | Behavior |
519+ | Value | Behavior |
520520| ----------------- | ------------------------------------------------------------------------------------ |
521521| omitted or empty | Reads the entire file as the credential. Leading and trailing whitespace is trimmed. |
522- | `json:<dot.path>` | Parses the file as JSON and extracts the value at the given dot-separated path. |
523- | anything else | Rejected with `unsupported parser : <value>`. |
522+ | `json:<dot.path>` | Parses the file as JSON and returns the value at the dot-separated path. |
523+ | any other value | Rejected — `unsupported parser : <value>`. |
524524
525- ` json:` is the only supported structured-file format.
525+ For `json:` paths, segments are separated by `.` (for example, `json:credentials.github.token`).
526+ Only object keys can be navigated — arrays are not supported and there is no `[0]`-style indexing.
527+ Keys that contain a literal `.` cannot be referenced. The resolved value must be a string, number,
528+ or boolean; numbers and booleans are converted to strings. Objects, arrays, and null are rejected.
526529
527- **JSON path rules**
530+ When a source has both `env` and `file` defined, `priority` controls which is tried first. If the
531+ preferred source is unavailable — file missing, field absent, or environment variable unset — the
532+ proxy falls back to the other source automatically.
528533
529- - Path segments are separated by `.` — for example, `json:credentials.github.token`.
530- - Only JSON objects can be navigated. Arrays are not supported; there is no `[0]`-style indexing.
531- - Keys that contain a literal `.` cannot be referenced — the dot is always treated as a separator.
532- - The value at the resolved path must be a string, number, or boolean. Numbers and booleans are
533- converted to strings. Objects, arrays, and null are rejected with
534- ` field '<path>' is not a string value` .
535-
536- **Priority and missing files**
537-
538- When a source has both `env` and `file`, `priority` controls which is tried first. If the
539- preferred source is unavailable (environment variable unset, or file missing or inaccessible),
540- the proxy falls back to the other source automatically. A missing file is not an error on its
541- own — the source is silently skipped.
542-
543- **Examples**
544-
545- Plain-text token file — no parser needed :
534+ Plain-text token file :
546535
547536` ` ` yaml
548537credentials:
@@ -552,34 +541,18 @@ credentials:
552541 path: "~/.openai/token"
553542` ` `
554543
555- Top-level JSON field :
556-
557- ` ` ` yaml
558- credentials:
559- sources:
560- anthropic:
561- file:
562- path: "~/.claude/settings.json"
563- parser: "json:primaryApiKey"
564- ` ` `
565-
566- Given `~/.claude/settings.json` :
567-
568- ` ` ` json
569- { "primaryApiKey": "sk-ant-...", "secondaryApiKey": "sk-ant-..." }
570- ` ` `
571-
572- The proxy resolves the credential to the value of `primaryApiKey`.
573-
574- Nested JSON field :
544+ Nested JSON field, with an environment variable as fallback :
575545
576546` ` ` yaml
577547credentials:
578548 sources:
579549 github:
550+ env:
551+ - GH_TOKEN
580552 file:
581553 path: "~/.config/myapp/creds.json"
582554 parser: "json:credentials.github.token"
555+ priority: file-first
583556` ` `
584557
585558Given `~/.config/myapp/creds.json` :
@@ -592,34 +565,17 @@ Given `~/.config/myapp/creds.json`:
592565}
593566` ` `
594567
595- The proxy resolves the credential to `ghp_xyz`.
596-
597- File-first with env fallback :
598-
599- ` ` ` yaml
600- credentials:
601- sources:
602- anthropic:
603- env:
604- - ANTHROPIC_API_KEY
605- file:
606- path: "~/.claude/settings.json"
607- parser: "json:primaryApiKey"
608- priority: file-first
609- ` ` `
610-
611- Tries the JSON file first; falls back to the environment variable if the file is
612- missing or the field is absent.
568+ The proxy resolves the credential to `ghp_xyz`, falling back to `GH_TOKEN` if the file is
569+ missing or the path doesn't resolve.
613570
614- ** Common errors**
571+ Common errors when using `json:` parsers :
615572
616573| Error message | Cause |
617574| --------------------------------------------- | ------------------------------------------------------------------- |
618575| `field 'X' not found in JSON` | The path doesn't exist in the file. |
619576| `cannot navigate to field 'X' : not an object` | A path segment hit a string, array, or scalar instead of an object. |
620577| `field 'X' is not a string value` | The resolved value is an object, array, or null. |
621578| `failed to parse JSON : ...` | The file is not valid JSON. |
622- | `unsupported parser : <value>` | The parser string doesn't start with `json:` and isn't empty. |
623579
624580# ## Network
625581
0 commit comments