Files
codex/codex-rs
T
charlesgong-openai 0065c3a17d [codex] Repair invalid skill frontmatter scalars (#28628)
## Why

The community marketplace audit found many skill frontmatter parse
failures where values were intended as prose, but were not valid YAML.
Common examples include unquoted scalar values with `: `, such as
`description: Build for AWS: ECS` or `argument-hint: <duration: e.g.
7d>`, and flow-looking values such as `tags: [next,@supabase/ssr]`.

`serde_yaml` does not expose a permissive mode for this. The parser
fails before unknown frontmatter fields can be ignored, so a
compatibility repair has to happen before retrying YAML parsing.

## What changed

Skill frontmatter loading still uses `serde_yaml` as the primary parser.
If that parse fails, the loader performs a line-oriented repair of
scalar frontmatter field values, then retries parsing.

The fallback now:

- applies to any frontmatter mapping field, not just `description` /
`short-description`
- quotes unquoted scalar values that contain a YAML colon separator such
as `: `
- quotes invalid flow-looking scalar values that start with `[`, `{`,
`@`, or backtick
- preserves already quoted values
- skips `|` / `>` block scalar bodies so multiline descriptions are not
rewritten
- returns the original YAML error if the repaired frontmatter still
cannot parse

## Examples

This previously failed because the second `: ` was parsed as YAML
structure:

```yaml
description: AWS deployment patterns: ECS Fargate, Lambda, and S3
```

The fallback now parses it as if it had been written explicitly as:

```yaml
description: 'AWS deployment patterns: ECS Fargate, Lambda, and S3'
```

The same repair now applies to ignored frontmatter fields that still
need to be valid YAML for the parser to get through the document:

```yaml
argument-hint: <duration: e.g. 7d, 2w>
tags: [next,@supabase/ssr]
```

Valid YAML multiline descriptions continue to work through normal
parsing without repair:

```yaml
description: |-
  Build for AWS: ECS
  and Lambda
```

## Validation

- Added loader coverage for unquoted `description` values containing `:
`.
- Added loader coverage for unquoted `metadata.short-description` values
containing `: ` and an apostrophe.
- Added loader coverage for unrecognized frontmatter fields that need
quoting, including `argument-hint` and `tags`.
- Added block-scalar coverage to ensure multiline description bodies are
preserved while other fields are repaired.
- `just test -p codex-core-skills` (106 passed)
- `just fix -p codex-core-skills`
0065c3a17d · 2026-06-17 10:37:14 -07:00
History
..
2026-06-04 09:16:03 -07:00