fix: limit CP template config transport
Some checks failed
Block internal-flavored paths / Block forbidden paths (push) Successful in 31s
CI / Detect changes (push) Successful in 58s
CI / Shellcheck (E2E scripts) (push) Successful in 42s
E2E API Smoke Test / detect-changes (push) Successful in 36s
Harness Replays / detect-changes (push) Successful in 19s
E2E Staging Canvas (Playwright) / detect-changes (push) Successful in 45s
Handlers Postgres Integration / detect-changes (push) Successful in 49s
E2E Staging SaaS (full lifecycle) / pr-validate (push) Successful in 1m4s
Secret scan / Scan diff for credential-shaped strings (push) Successful in 27s
Runtime PR-Built Compatibility / detect-changes (push) Successful in 57s
E2E Staging SaaS (full lifecycle) / E2E Staging SaaS (push) Successful in 5m22s
Harness Replays / Harness Replays (push) Successful in 29s
E2E Staging Canvas (Playwright) / Canvas tabs E2E (push) Successful in 36s
CI / Python Lint & Test (push) Successful in 7m45s
E2E API Smoke Test / E2E API Smoke Test (push) Successful in 3m39s
Runtime PR-Built Compatibility / PR-built wheel + import smoke (push) Successful in 3m40s
Sweep stale Cloudflare Tunnels / Sweep CF tunnels (push) Successful in 38s
publish-workspace-server-image / build-and-push (push) Successful in 11m58s
Handlers Postgres Integration / Handlers Postgres Integration (push) Successful in 6m57s
CI / Canvas (Next.js) (push) Successful in 17m14s
CI / Canvas Deploy Reminder (push) Successful in 7s
CI / Platform (Go) (push) Failing after 17m57s
publish-workspace-server-image / Production auto-deploy (push) Failing after 2m37s
CI / all-required (push) Failing after 17m57s
Staging SaaS smoke (every 30 min) / Staging SaaS smoke (push) Successful in 4m57s
main-red-watchdog / watchdog (push) Successful in 57s
gate-check-v3 / gate-check (push) Successful in 24s
Sweep stale e2e-* orgs (staging) / Sweep e2e orgs (push) Successful in 2s
Sweep stale Cloudflare DNS records / Sweep CF orphans (push) Successful in 11s
ci-required-drift / drift (push) Successful in 1m0s
status-reaper / reap (push) Has started running
Continuous synthetic E2E (staging) / Synthetic E2E against staging (push) Successful in 5m4s
gitea-merge-queue / queue (push) Compensated by status-reaper (workflow has no push: trigger; Gitea 1.22.6 hardcoded-suffix bug — see .gitea/scripts/status-reaper.py)

This commit is contained in:
Molecule merge queue 2026-05-14 15:37:44 -07:00
parent 7b3e3fc189
commit 8fced20267
2 changed files with 15 additions and 0 deletions

View File

@ -248,6 +248,11 @@ func (p *CPProvisioner) Start(ctx context.Context, cfg WorkspaceConfig) (string,
const cpConfigFilesMaxBytes = 12 << 10
func isCPTemplateConfigFile(name string) bool {
name = filepath.ToSlash(filepath.Clean(name))
return name == "config.yaml" || strings.HasPrefix(name, "prompts/")
}
func collectCPConfigFiles(cfg WorkspaceConfig) (map[string]string, error) {
files := make(map[string]string)
total := 0
@ -301,6 +306,9 @@ func collectCPConfigFiles(cfg WorkspaceConfig) (map[string]string, error) {
if err != nil {
return err
}
if !isCPTemplateConfigFile(rel) {
return nil
}
data, err := os.ReadFile(path)
if err != nil {
return err

View File

@ -1,6 +1,7 @@
package provisioner
import (
"bytes"
"context"
"encoding/base64"
"encoding/json"
@ -221,6 +222,9 @@ func TestStart_SendsTemplateAndGeneratedConfigFiles(t *testing.T) {
if err := os.WriteFile(filepath.Join(tmpl, "config.yaml"), []byte("name: template\n"), 0o600); err != nil {
t.Fatal(err)
}
if err := os.WriteFile(filepath.Join(tmpl, "adapter.py"), bytes.Repeat([]byte("x"), cpConfigFilesMaxBytes), 0o600); err != nil {
t.Fatal(err)
}
if err := os.Mkdir(filepath.Join(tmpl, "prompts"), 0o700); err != nil {
t.Fatal(err)
}
@ -261,6 +265,9 @@ func TestStart_SendsTemplateAndGeneratedConfigFiles(t *testing.T) {
if got := body.ConfigFiles["prompts/system.md"]; got != wantPrompt {
t.Errorf("prompt payload = %q, want %q", got, wantPrompt)
}
if _, ok := body.ConfigFiles["adapter.py"]; ok {
t.Error("non-config template file adapter.py must not be sent to CP")
}
}
// TestStart_Non201ReturnsStructuredError — when CP returns 401 with a