Skip to content

fix: region bug and minor UI changes#11

Merged
faloker merged 8 commits into
mainfrom
fix/region-bug-and-ui
Jun 23, 2026
Merged

fix: region bug and minor UI changes#11
faloker merged 8 commits into
mainfrom
fix/region-bug-and-ui

Conversation

@faloker

@faloker faloker commented Jun 23, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fixes a region-mismatch bug that caused detonations to act on the wrong AWS region (producing NotFound errors), preserves execution_id on detonation failures so partial runs stay correlatable, reclaims Terraform working directories on run deletion, and ships several minor UI fixes (toast notifications, retention/pack validation, scenario links).

Bug Fixes

  • Align detonation region with the Terraform provider region. Terraform pins the AWS provider to var.aws_region, but the detonation resolved its region from the container's ambient AWS_REGION via the SDK default chain. When they diverged, Terraform created resources in one region while the detonation acted on another — surfacing as NotFound. A new detonationEnvVars now pins AWS_REGION/AWS_DEFAULT_REGION to the resolved aws_region, mirroring terraformEnvVars precedence (per-sim > pack-level > built-in default). DefaultAWSRegion is extracted as a shared constant in pack/builtins.go.
  • Preserve execution_id on failure paths. SimrunDetonator.Detonate and Runner.runScenario now carry the execution_id out on every failure past ID generation, so a partially-completed detonation (e.g. Terraform applied, then a timeout) stays correlatable in the persisted result instead of returning a nil/empty map.
  • Fix scenario link on the assessment detail page. The scenario name now links to /scenarios/{scenarioId} instead of the generic /scenarios list.

Terraform Directory Cleanup

  • Reclaim Terraform working dirs on run deletion. deleteRunWithArtifacts (shared by manual delete and the retention sweeper) now best-effort removes <DataDir>/terraform/<execution_id>/ for each scenario result via os.RemoveAll. Blank/whitespace or path-bearing execution IDs are skipped so cleanup can never escape or wipe the terraform/ base. Accompanied by the archived OpenSpec change (purge-terraform-dirs) and updated runs spec.

UI Changes

  • Toast notifications for delete operations. Pack, assessment, and scenario deletes now surface success/error via svelte-sonner toasts instead of failing silently or rendering inline errors. Toaster repositioned to top-center.
  • Retention dialog respects disabled sections. Day-value validation now only fires for an enabled section, and a disabled section keeps its stored value rather than PUTting an empty/greyed-out field (which the backend would reject with HTTP 400).
  • Reject blank keys/values in string-map pack params. PackParametersDialog now validates string-map params (e.g. default_tags) up front, since empty tag keys/values can't be applied by Terraform/cloud providers and would silently break every sim in the pack.

Tests

  • New tests for region resolution precedence (TestDetonationEnvVars_AWSRegion), failure-path execution_id preservation, and Terraform-dir cleanup (removal, unsafe-ID skip, missing-dir best-effort).

Copilot AI review requested due to automatic review settings June 23, 2026 00:11
@github-actions github-actions Bot added the size/XL PR size: XL label Jun 23, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses a region-mismatch bug in pack detonations, improves deletion cleanup to reclaim Terraform working directories, and makes a few UI/UX tweaks (toast notifications, links, toaster placement) alongside updated OpenSpec documentation.

Changes:

  • Pin detonation AWS region (AWS_REGION / AWS_DEFAULT_REGION) to the resolved aws_region parameter to prevent cross-region NotFound issues.
  • Extend run deletion to best-effort remove Terraform working directories keyed by scenario_results.execution_id, with tests and spec updates.
  • UI: replace inline delete errors with toast notifications, adjust toaster position, and link assessment run details directly to the scenario.

Reviewed changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
web/frontend/src/routes/scenarios/+page.svelte Uses toast notifications for scenario deletion feedback.
web/frontend/src/routes/assessments/+page.svelte Uses toast notifications for assessment deletion feedback.
web/frontend/src/routes/assessments/[runId]/+page.svelte Links run details to the specific scenario route.
web/frontend/src/routes/+layout.svelte Moves toaster position to top-center.
web/frontend/src/lib/components/RetentionDialog.svelte Avoids PUT-ing invalid days for disabled retention sections.
web/frontend/src/lib/components/PackParametersDialog.svelte Validates string-map parameters to prevent blank keys/values.
web/frontend/src/lib/components/PackCard.svelte Adds toast success/error feedback on pack deletion.
pack/builtins.go Exposes DefaultAWSRegion constant for shared defaulting.
internal/detonators/simrun_detonator.go Ensures execution_id is returned on failure paths; pins AWS region env for detonation.
internal/detonators/simrun_detonator_test.go Adds tests for detonation AWS region env precedence/defaulting.
internal/runner/runner.go Preserves execution_id even when scenario execution fails.
internal/runner/runner_test.go Updates tests to assert failed scenarios retain execution_id.
internal/web/run_deletion.go Adds best-effort Terraform-dir cleanup on run deletion.
internal/web/retention_test.go Adds sweep tests ensuring Terraform dirs are removed/skipped safely.
openspec/specs/runs/spec.md Updates delete-run requirement to include Terraform-dir cleanup constraints.
openspec/changes/archive/2026-06-22-purge-terraform-dirs/tasks.md Archived change task checklist for Terraform-dir purge work.
openspec/changes/archive/2026-06-22-purge-terraform-dirs/specs/runs/spec.md Archived snapshot of modified run-delete requirements.
openspec/changes/archive/2026-06-22-purge-terraform-dirs/proposal.md Archived proposal describing motivation and impact.
openspec/changes/archive/2026-06-22-purge-terraform-dirs/design.md Archived design covering safety decisions and risks.
openspec/changes/archive/2026-06-22-purge-terraform-dirs/.openspec.yaml Archived OpenSpec metadata for the change.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +73 to +83
for _, id := range executionIDs {
if strings.TrimSpace(id) == "" ||
strings.ContainsRune(id, '/') || strings.ContainsRune(id, filepath.Separator) {
continue
}
dir := filepath.Join(dataDir, "terraform", id)
if err := os.RemoveAll(dir); err != nil && !os.IsNotExist(err) {
logrus.WithError(err).WithField("path", dir).WithField("run_id", runID).
Warn("failed to remove Terraform working directory")
}
}
Comment thread internal/web/retention_test.go Outdated
Comment on lines +182 to +183
for _, execID := range []string{"", " ", "../escape", "nested/id"} {
t.Run("id="+execID, func(t *testing.T) {
Comment thread openspec/specs/runs/spec.md
Comment thread web/frontend/src/routes/scenarios/+page.svelte
Comment thread web/frontend/src/routes/assessments/+page.svelte
@faloker faloker merged commit 863a6ca into main Jun 23, 2026
2 of 3 checks passed
@faloker faloker deleted the fix/region-bug-and-ui branch June 23, 2026 00:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/XL PR size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants