Skip to content

Comments

fix: sandbox creation blocked by retention validation gap and Kafka trigger cloning#4439

Open
elias-ba wants to merge 7 commits intomainfrom
4385-fix-retention-validation-sandbox-creation
Open

fix: sandbox creation blocked by retention validation gap and Kafka trigger cloning#4439
elias-ba wants to merge 7 commits intomainfrom
4385-fix-retention-validation-sandbox-creation

Conversation

@elias-ba
Copy link
Contributor

@elias-ba elias-ba commented Feb 19, 2026

Description

This PR fixes several issues blocking sandbox creation:

  1. Retention validation gap - validate_dataclip_retention_period/1 used get_change/2 which only returns a value when the field is modified. When a user changes only history_retention_period, the cross-field check is skipped, allowing dataclip_retention_period > history_retention_period to be saved. This invalid state then blocks sandbox creation because the cloned settings get rejected by validation. Fixed by using get_field/2 instead.

  2. Kafka trigger cloning crash - Sandbox creation crashes with Ecto.CastError for any project with a Kafka trigger. The cloning code passes the loaded %KafkaConfiguration{} struct directly to Trigger.changeset/2, but cast_embed expects a plain map. Fixed by converting the struct to a map before passing it.

  3. Silent form failure - When sandbox creation fails due to a backend validation error, the form failed silently (no error message, name field emptied). Fixed by closing the modal and redirecting with a flash error, consistent with how the limiter error is handled.

  4. Data migration - Aligns dataclip_retention_period to history_retention_period for projects currently in the invalid state.

Closes #4385
Closes #4440

Validation steps

  1. On staging, go to qa-workflows and create a new sandbox, it should succeed (this project previously had inconsistent retention settings that blocked sandbox creation).
  2. Create a sandbox from a project that has a Kafka trigger, it should succeed without crashing.
  3. In any project's settings, set a dataclip retention period and try lowering the history retention period below it, the form should reject the change with a validation error.

Additional notes for the reviewer

AI Usage

  • I have used Claude Code
  • I have used another model
  • I have not used AI

Pre-submission checklist

  • I have performed an AI review of my code (we recommend using /review with Claude Code)
  • I have implemented and tested all related authorization policies. (e.g., :owner, :admin, :editor, :viewer)
  • I have updated the changelog.
  • I have ticked a box in "AI usage" in this PR

Use get_field instead of get_change in validate_dataclip_retention_period
so the cross-field check runs even when only history_retention_period is
changed. Also fix the sandbox form error branch to preserve form state
and show a flash message on backend validation errors.
@github-project-automation github-project-automation bot moved this to New Issues in v2 Feb 19, 2026
@codecov
Copy link

codecov bot commented Feb 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.31%. Comparing base (9919348) to head (ea7933f).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4439      +/-   ##
==========================================
- Coverage   89.37%   89.31%   -0.07%     
==========================================
  Files         425      425              
  Lines       20149    20154       +5     
==========================================
- Hits        18009    18001       -8     
- Misses       2140     2153      +13     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

- Redirect to sandboxes page with flash on backend changeset error
  instead of keeping modal open (flash was hidden behind modal)
- Convert KafkaConfiguration struct to map before passing to
  cast_embed during trigger cloning (fixes sandbox creation for
  projects with Kafka triggers)
@elias-ba elias-ba changed the title fix: retention validation gap blocking sandbox creation fix: sandbox creation blocked by retention validation gap and Kafka trigger cloning Feb 19, 2026
Sets dataclip_retention_period = history_retention_period for projects
where dataclip_retention_period > history_retention_period. Three
projects on prod are currently in this invalid state due to the
validation gap fixed in a63b140.
Log changeset errors server-side when sandbox creation fails so
operators can diagnose issues. Expand changelog to cover all three
fixes (retention validation, Kafka trigger cloning, silent form error).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: New Issues

Development

Successfully merging this pull request may close these issues.

Sandbox creation crashes for projects with Kafka triggers Can't Create a Sandbox in Certain Projects

2 participants