Skip to content

Commit a7a123d

Browse files
daanvinkenCopilot
andauthored
Potential fix for pull request finding
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Daan Vinken <daanvinken@tythus.com>
1 parent 5488b8f commit a7a123d

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

server/core/runtime/s3_plan_store.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,18 @@ func (s *S3PlanStore) Load(ctx command.ProjectContext, planPath string) error {
144144
// Reject stale plans: the plan must have been created at the same commit
145145
// the PR currently points to. This prevents applying outdated plans after
146146
// new commits are pushed (e.g. across pod restarts).
147-
// Note: S3 normalizes user-defined metadata keys to title case in responses,
148-
// so "head-commit" (as written in Save) becomes "Head-Commit" here.
149-
planCommit := resp.Metadata["Head-Commit"]
147+
// the PR currently points to. This prevents applying outdated plans after
148+
// new commits are pushed (e.g. across pod restarts).
149+
// Note: different S3/S3-compatible implementations may return user-defined
150+
// metadata keys with different casing, so we look up "head-commit"
151+
// case-insensitively.
152+
var planCommit string
153+
for k, v := range resp.Metadata {
154+
if strings.EqualFold(k, "head-commit") {
155+
planCommit = v
156+
break
157+
}
158+
}
150159
if planCommit == "" {
151160
return fmt.Errorf("plan in S3 has no head-commit metadata (key=%s) — run plan again", key)
152161
}

0 commit comments

Comments
 (0)