[BUG] Flat hook entries without `type` reach `.codex/hooks.json` without the required `type: command`
I maintainer di solito rispondono entro 2 giorni
@Parth-Vasave ci sta già lavorando.
Dal 16/10/2026.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 75/100
Direzione di ricerca
Segui il percorso di rendering degli hook di Codex che converte le voci degli hook piatte in gruppi { "matcher", "hooks": [...] }; l’issue non indica il file del progetto, quindi individua prima il renderer e i relativi test. Riproduci il problema con il flat.json fornito e l’esempio apm install, poi verifica che un handler senza tipo venga renderizzato con "type": "command", mentre gli handler con tipo esplicito rimangano invariati.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Describe the bug
Some hook files use the flat entry shape without a type field (valid in Cursor, where type defaults to command). For such entries, the codex render wraps them into { "matcher", "hooks": [...] } groups (the native shape from #3059 / #3060) but does not add "type": "command" to the handler.
Codex's hook schema requires that field. In openai/codex, MatcherGroup.hooks is Vec<HookHandlerConfig>, and HookHandlerConfig is an internally tagged enum (#[serde(tag = "type")]) with command, mcp_tool and prompt variants and no default (codex-rs/config/src/hook_config.rs). An untyped handler therefore does not match any variant. @MohammedAlkindi pointed this out in a review of #3153.
This is the Codex counterpart of #3130. The Claude fix in #3153 deliberately leaves Codex unchanged, because #3130's approved scope excludes automatic Codex changes.
To Reproduce
demo-pkg/apm.yml
name: demo-pkg
version: 0.0.1
targets: [codex]
demo-pkg/.apm/hooks/flat.json (PascalCase event, so only the missing type is in play)
{ "version": 1, "hooks": { "PreToolUse": [ { "command": "node \"${PLUGIN_ROOT}/.apm/hooks/scripts/gate.mjs\"", "matcher": "Write", "timeout": 10 } ] } }
demo-pkg/.apm/hooks/scripts/gate.mjs
process.exit(0);
consumer/apm.yml
name: consumer
version: 0.0.1
targets: [codex]
dependencies:
apm:
- path: ../demo-pkg
cd consumer
mkdir .codex
apm install
Actual .codex/hooks.json
{
"hooks": {
"PreToolUse": [
{
"matcher": "Write",
"hooks": [
{
"command": "node \".codex/hooks/demo-pkg/.apm/hooks/scripts/gate.mjs\"",
"timeout": 10
}
]
}
]
}
}
Expected behavior
The handler should get "type": "command", as Codex's schema requires:
{ "type": "command", "command": "node \".codex/hooks/demo-pkg/.apm/hooks/scripts/gate.mjs\"", "timeout": 10 }
Explicitly typed handlers should stay as authored.
Environment (please complete the following information):
- OS: macOS 27.0.1
- Python Version: 3.12.12
- APM Version: 0.33.0 (source checkout of
mainat6333b56a; also reproduced on the #3153 headbbd89bf3)
Logs
Install succeeds with no warning about the handler:
[i] Targets: codex (source: apm.yml)
[+] ../demo-pkg (local)
|-- 1 hook(s) integrated -> .codex/hooks.json
| PreToolUse: runs .codex/hooks/demo-pkg/.apm/hooks/scripts/gate.mjs (flat.json)
[*] Installed 1 APM dependency in 0.1s.
Additional context
- This is a schema finding from Codex's source. I have not separately confirmed how a Codex runtime reports or handles the invalid entry.
- Related: #3130 / #3153 (same gap for Claude, fixed Claude-only), #3059 / #3060 (Codex nested
hookslevel, where every example was already typed), #2111 (broader hook semantics work). - Separate from this issue: with a camelCase event such as
preToolUse(as in #3130's repro), the Codex render also keeps the event name and warns that Codex expects PascalCase. That event-name mapping was out of #3130's scope, and I have not included it here.
- Lingua principale
- Python
- Stelle
- 4k
- Fork
- 387
- Merge medio
- 5g 44m
- PR unite (30g)
- 60
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un 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 microsoft/apm
-
status/accepted
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
microsoft/apm#3259 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
-
type/bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 2 giorni
-
type/automation type/performance
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 2 giorni
-
status/declined type/bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 92/100
microsoft/apm#3169 · 2 commenti ·
I maintainer di solito rispondono entro 2 giorni
Tutte le issue di microsoft/apm
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
TomerAberbach/profiler-md#733 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
its-me-prash/vwgroup-connect-ha#1858 ·
I maintainer di solito rispondono entro 1 giorno
-
area: client bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno
-
Deleting all alarms or timers shows deleted ones until the next update when there are none leftApertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
leikoilja/ha-google-home#1107 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
Graphify-Labs/graphify#4524 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno