Commit 841459b
fix(control-plane): prevent structured logs from leaking execution payloads (#701)
* fix(control-plane): prevent structured logs from leaking execution payloads (#560)
Add logging configuration (level + redact_payloads) to control what
execution data appears in structured log events and the internal event bus.
Changes:
- Add LoggingConfig with 'level' and 'redact_payloads' options
- Support AGENTFIELD_LOG_LEVEL and AGENTFIELD_LOG_REDACT_PAYLOADS env vars
- Guard execution input/output/context in event publishing behind redaction flag
- Default to redact_payloads=true (safe) — opt-in via config to see full payloads
- Replace 32 log.Printf calls in storage layer with leveled logger.Logger calls
- Add InitLoggerWithLevel() for string-based log level configuration
- Re-initialize logger from config at server startup
Closes #560
* fix: address Copilot review comments
- Guard req.Result behind redactPayloads in handleStatusUpdate event data
- Remove raw data preview from corrupted JSON warning log (log only metadata: context + length)
* test(control-plane): cover payload redaction branches for patch-coverage gate (#701)
The structured-log payload redaction added in #701 gated execution
input/result/context data behind `redactPayloads`. Those branches were only
exercised on their redact-enabled default, leaving the opt-out paths uncovered
and dropping control-plane patch coverage below the 80% floor.
Adds behavior tests that subscribe to the execution event bus and assert the
observable contract: input/result/context payloads are omitted from published
events when redaction is enabled (the safe default) and present only when an
operator explicitly disables it. Covers completeExecution, failExecution,
completeReplayHit, handleStatusUpdate, and the event-context path.
Patch coverage on touched lines: 68% -> 93%. Additive only; does not weaken the
redaction logic.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Abir Abbas <abirabbas1998@gmail.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 7eb7ab5 commit 841459b
13 files changed
Lines changed: 642 additions & 78 deletions
File tree
- control-plane
- cmd/agentfield-server
- config
- internal
- config
- handlers
- logger
- server
- storage
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
70 | 71 | | |
71 | 72 | | |
72 | 73 | | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
73 | 81 | | |
74 | 82 | | |
75 | 83 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
24 | 41 | | |
25 | 42 | | |
26 | 43 | | |
| |||
468 | 485 | | |
469 | 486 | | |
470 | 487 | | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
471 | 491 | | |
472 | 492 | | |
473 | 493 | | |
| |||
781 | 801 | | |
782 | 802 | | |
783 | 803 | | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
784 | 813 | | |
785 | 814 | | |
786 | 815 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
491 | 491 | | |
492 | 492 | | |
493 | 493 | | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
132 | 132 | | |
133 | 133 | | |
134 | 134 | | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
143 | 144 | | |
144 | 145 | | |
145 | 146 | | |
| |||
166 | 167 | | |
167 | 168 | | |
168 | 169 | | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
169 | 175 | | |
170 | 176 | | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
171 | 183 | | |
172 | 184 | | |
173 | 185 | | |
| |||
225 | 237 | | |
226 | 238 | | |
227 | 239 | | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | | - | |
232 | | - | |
233 | | - | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
234 | 247 | | |
235 | 248 | | |
236 | 249 | | |
| |||
953 | 966 | | |
954 | 967 | | |
955 | 968 | | |
956 | | - | |
957 | 969 | | |
958 | 970 | | |
959 | 971 | | |
960 | 972 | | |
961 | 973 | | |
962 | 974 | | |
963 | | - | |
964 | | - | |
| 975 | + | |
| 976 | + | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
965 | 980 | | |
966 | 981 | | |
967 | 982 | | |
| |||
1076 | 1091 | | |
1077 | 1092 | | |
1078 | 1093 | | |
1079 | | - | |
| 1094 | + | |
1080 | 1095 | | |
1081 | 1096 | | |
1082 | 1097 | | |
| |||
1694 | 1709 | | |
1695 | 1710 | | |
1696 | 1711 | | |
1697 | | - | |
1698 | 1712 | | |
1699 | | - | |
1700 | | - | |
| 1713 | + | |
| 1714 | + | |
| 1715 | + | |
| 1716 | + | |
| 1717 | + | |
1701 | 1718 | | |
1702 | 1719 | | |
1703 | 1720 | | |
| |||
1871 | 1888 | | |
1872 | 1889 | | |
1873 | 1890 | | |
1874 | | - | |
1875 | | - | |
1876 | | - | |
1877 | | - | |
1878 | | - | |
| 1891 | + | |
| 1892 | + | |
| 1893 | + | |
| 1894 | + | |
| 1895 | + | |
| 1896 | + | |
| 1897 | + | |
1879 | 1898 | | |
1880 | 1899 | | |
1881 | 1900 | | |
| |||
1955 | 1974 | | |
1956 | 1975 | | |
1957 | 1976 | | |
1958 | | - | |
1959 | | - | |
1960 | | - | |
1961 | | - | |
1962 | | - | |
| 1977 | + | |
| 1978 | + | |
| 1979 | + | |
| 1980 | + | |
| 1981 | + | |
| 1982 | + | |
| 1983 | + | |
1963 | 1984 | | |
1964 | 1985 | | |
1965 | 1986 | | |
| |||
0 commit comments