MCPcopy Create free account
hub / github.com/github/gh-aw / warnPromptTmpPaths

Function warnPromptTmpPaths

pkg/workflow/compiler_validators.go:65–85  ·  view source on GitHub ↗

warnPromptTmpPaths returns a non-empty advisory message when content contains tmp/ references that are not under /tmp/gh-aw/. Returns an empty string when no problematic patterns are found.

(content string)

Source from the content-addressed store, hash-verified

63// /tmp/ references that are not under /tmp/gh-aw/.
64// Returns an empty string when no problematic patterns are found.
65func warnPromptTmpPaths(content string) string {
66 if !strings.Contains(content, tmpNeedle) {
67 return ""
68 }
69 // Walk every /tmp/ occurrence; warn as soon as one is not under /tmp/gh-aw/.
70 rest := content
71 for {
72 pos := strings.Index(rest, tmpNeedle)
73 if pos < 0 {
74 break
75 }
76 segment := rest[pos:]
77 if !strings.HasPrefix(segment, tmpSafePrefix) {
78 return "Prompt references /tmp/ directly. " +
79 "Use /tmp/gh-aw/agent/ as the root for all temporary files " +
80 "generated by the agent — its contents are uploaded as a run artifact."
81 }
82 rest = rest[pos+len(tmpNeedle):]
83 }
84 return ""
85}
86
87// validatePromptTmpPaths emits an advisory warning when the workflow markdown body
88// references /tmp/ or /tmp/gh-aw/ instead of the recommended /tmp/gh-aw/agent/ root.

Callers 2

TestWarnPromptTmpPathsFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestWarnPromptTmpPathsFunction · 0.68