Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

[BUG] Flat hook entries without `type` reach `.codex/hooks.json` without the required `type: command`

Aperta Adatta ai principianti
#3,249 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

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
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
json, python
Ambito
backend

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 main at 6333b56a; also reproduced on the #3153 head bbd89bf3)

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 hooks level, 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

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di microsoft/apm

Tutte le issue di microsoft/apm

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.