Commit a7afcbb
fix(server): snapshot raw_params before hook to preserve context-echo contract
Both code-reviewer and dx-expert expert review flagged that assigning
raw_params after the hook would echo server-injected defaults back to the
buyer as if they were sent on the wire, violating the AdCP context-echo
contract. Move the snapshot to before the hook call (raw_params = params),
so inject_context always uses the original wire dict regardless of what
the hook returns or mutates.
Also strengthens test_hook_does_not_pollute_context_echo: the previous test
passed a copy of the outer dict so the assertion was trivially true. The
new test sends a wire payload with a context field, uses a stripping hook
that returns a completely new dict (no context key), and asserts the
response context echo still carries the original wire context — only possible
if raw_params was captured before the hook ran.
https://claude.ai/code/session_015hHQqXRbn2jX9WTu564gjZ1 parent b31f335 commit a7afcbb
2 files changed
Lines changed: 27 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1956 | 1956 | | |
1957 | 1957 | | |
1958 | 1958 | | |
| 1959 | + | |
| 1960 | + | |
1959 | 1961 | | |
1960 | 1962 | | |
1961 | 1963 | | |
| |||
1970 | 1972 | | |
1971 | 1973 | | |
1972 | 1974 | | |
1973 | | - | |
1974 | | - | |
1975 | 1975 | | |
1976 | 1976 | | |
1977 | 1977 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
152 | 158 | | |
153 | | - | |
| 159 | + | |
| 160 | + | |
154 | 161 | | |
155 | | - | |
156 | | - | |
157 | | - | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
158 | 165 | | |
159 | 166 | | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
164 | 174 | | |
165 | 175 | | |
166 | 176 | | |
| |||
0 commit comments