Skip to content

Commit daeebff

Browse files
Add debug logging to under-instrumented threat-detection, frontmatter, and validation paths (#51676)
1 parent 8f8119b commit daeebff

5 files changed

Lines changed: 18 additions & 0 deletions

pkg/workflow/create_entity_helpers.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ func parseCreateEntityConfig[T any](
4848
configData = nil
4949
}
5050
if preUnmarshal != nil && !preUnmarshal(configData) {
51+
debugLog.Printf("preUnmarshal aborted parsing for %s", configKey)
5152
return nil
5253
}
5354

@@ -72,11 +73,13 @@ func parseCreateEntityConfig[T any](
7273

7374
config := parseConfigScaffold(outputMap, configKey, debugLog, onError)
7475
if config == nil {
76+
debugLog.Printf("parseConfigScaffold returned nil config for %s", configKey)
7577
return nil
7678
}
7779

7880
if postUnmarshal != nil {
7981
postUnmarshal(configData, config, expiresDisabled)
82+
debugLog.Printf("postUnmarshal applied for %s (expiresDisabled=%t)", configKey, expiresDisabled)
8083
}
8184

8285
return config

pkg/workflow/frontmatter_on_section_cleanup.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ func (c *Compiler) commentOutProcessedFieldsInOnSection(yamlStr string, frontmat
3434
}
3535

3636
result = dedentTrailingOnCommentBlock(result)
37+
frontmatterLog.Printf("Processed 'on' section: %d input lines, %d native label filter section(s)", len(lines), len(nativeLabelFilterSections))
3738
return strings.Join(result, "\n")
3839
}
3940

@@ -149,6 +150,7 @@ func (s *onSectionCleanupState) detectEventSection(info onSectionLine) (string,
149150
}
150151

151152
func (s *onSectionCleanupState) activateEventSection(section string, indent int) {
153+
frontmatterLog.Printf("Entering event section %q at indent %d", section, indent)
152154
s.resetTopLevelExtensionState()
153155
s.inCommentBlock = false
154156
s.commentBlockIndent = ""
@@ -668,6 +670,7 @@ func dedentTrailingOnCommentBlock(lines []string) []string {
668670
}
669671
}
670672

673+
frontmatterLog.Printf("Dedenting trailing 'on' comment block: lines %d-%d", start, last)
671674
for i := start; i <= last; i++ {
672675
lines[i] = strings.TrimLeft(lines[i], " \t")
673676
}

pkg/workflow/strict_mode_sandbox_validation.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,10 @@ func (c *Compiler) validateStrictSandboxCustomization(sandboxConfig *SandboxConf
5353
"Remove 'sudo: true' to use the secure default. " +
5454
"See: https://github.github.com/gh-aw/reference/sandbox/"
5555
if c.strictMode {
56+
strictModeValidationLog.Print("Rejecting sandbox.agent.sudo: true in strict mode")
5657
return fmt.Errorf("strict mode: %s", sudoTrueMsg)
5758
}
59+
strictModeValidationLog.Print("Warning about deprecated sandbox.agent.sudo: true in non-strict mode")
5860
fmt.Fprintln(os.Stderr, console.FormatWarningMessage(sudoTrueMsg))
5961
c.IncrementWarningCount()
6062
}
@@ -86,6 +88,7 @@ func (c *Compiler) validateStrictSandboxCustomization(sandboxConfig *SandboxConf
8688

8789
// Check MCP gateway internal fields
8890
if mcp := sandboxConfig.MCP; mcp != nil {
91+
strictModeValidationLog.Print("Checking sandbox.mcp internal fields against strict mode restrictions")
8992
if mcp.Container != "" {
9093
return internalSandboxFieldError("sandbox.mcp.container")
9194
}

pkg/workflow/threat_detection_external.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,10 @@ func (c *Compiler) buildPullAWFContainersStep(data *WorkflowData) []string {
132132

133133
images := collectDockerImages(detectionData.Tools, detectionData, c.actionMode)
134134
if len(images) == 0 {
135+
threatLog.Print("No AWF container images to pre-pull for detection job")
135136
return nil
136137
}
138+
threatLog.Printf("Pre-pulling %d AWF container image(s) for detection job", len(images))
137139

138140
var b strings.Builder
139141
generateDownloadDockerImagesStep(&b, images)
@@ -224,6 +226,7 @@ func (c *Compiler) buildInstallAWFForExternalDetectorStep(data *WorkflowData) []
224226
version = firewallConfig.Version
225227
}
226228

229+
threatLog.Printf("Building AWF installation step for external detector (version=%s)", version)
227230
step := generateAWFInstallationStep(version, nil)
228231
if len(step) == 0 {
229232
return nil
@@ -297,6 +300,7 @@ func (c *Compiler) buildExternalDetectorExecutionStep(data *WorkflowData) []stri
297300
engineID := c.getExternalThreatDetectionEngineID(data)
298301
engine, err := c.getAgenticEngine(engineID)
299302
if err != nil {
303+
threatLog.Printf("Failed to resolve detection engine %q for external detector execution: %v", engineID, err)
300304
return []string{fmt.Sprintf(" # Failed to resolve detection engine %q: %v\n", engineID, err)}
301305
}
302306

pkg/workflow/threat_detection_inline_engine.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ func (c *Compiler) buildDetectionEngineExecutionStep(data *WorkflowData) []strin
1717
if data.SafeOutputs != nil && data.SafeOutputs.ThreatDetection != nil {
1818
if data.SafeOutputs.ThreatDetection.EngineDisabled {
1919
// Engine explicitly disabled with engine: false
20+
threatLog.Print("Threat detection engine explicitly disabled via engine: false")
2021
return []string{
2122
" # AI engine disabled for threat detection (engine: false)\n",
2223
}
@@ -49,6 +50,7 @@ func (c *Compiler) buildDetectionEngineExecutionStep(data *WorkflowData) []strin
4950
// Get the engine instance
5051
engine, err := c.getAgenticEngine(engineSetting)
5152
if err != nil {
53+
threatLog.Printf("Detection engine %q not found, skipping execution: %v", engineSetting, err)
5254
return []string{" # Engine not found, skipping execution\n"}
5355
}
5456

@@ -113,6 +115,8 @@ func (c *Compiler) buildDetectionEngineExecutionStep(data *WorkflowData) []strin
113115
resolvedDetectionModel = extractPiModelID(resolvedDetectionModel)
114116
}
115117

118+
threatLog.Printf("Resolved inline detection engine %q (original=%q) with model %q", engineSetting, originalEngineID, resolvedDetectionModel)
119+
116120
// Create minimal WorkflowData for threat detection.
117121
// SandboxConfig with AWF enabled ensures the engine runs inside the firewall.
118122
// NetworkPermissions.Allowed preserves only literal user-specified domains when Copilot
@@ -154,6 +158,7 @@ func (c *Compiler) buildDetectionEngineExecutionStep(data *WorkflowData) []strin
154158
// via BuildStandardNpmEngineInstallSteps) — a duplicate would trip
155159
// JobManager.ValidateDuplicateSteps and hard-fail the compile.
156160
if engineRequiresNodeHarness(engine) && !installStepsContainNodeSetup(installSteps) {
161+
threatLog.Print("Injecting Node.js setup step for detection engine harness")
157162
for _, line := range GenerateNodeJsSetupStep() {
158163
steps = append(steps, line+"\n")
159164
}

0 commit comments

Comments
 (0)