Commit c113e81
committed
fix: walk full ancestor chain in addGatewayFlags PersistentPreRunE
addGatewayFlags overrides the command's PersistentPreRunE to inject
gateway/model config. At the end of the hook it chains to the original
PersistentPreRunE, falling back to cmd.Parent().PersistentPreRunE when
there is none.
That single-level parent check breaks when the command is nested more
than one level deep. For example, with root → serve → api, the
immediate parent (serve) has no PersistentPreRunE, so the root's hook
(which sets up file logging, telemetry, etc.) was silently skipped.
Replace the single parent check with a loop that walks up the full
ancestor chain until a PersistentPreRunE is found, matching the
behaviour Cobra itself uses when traversing persistent pre-run hooks.1 parent f39705d commit c113e81
2 files changed
Lines changed: 39 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
101 | | - | |
102 | | - | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
103 | 109 | | |
104 | 110 | | |
105 | 111 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
101 | 132 | | |
102 | 133 | | |
103 | 134 | | |
| |||
0 commit comments