fix: Remove automatic default injection in StatusPageService.onBeforeCreate #153

Closed
opened 2026-04-05 16:18:58 +02:00 by MrUnknownDE · 0 comments
Owner

Originally created by @listellm on 1/19/2026

Summary

Fixes #2232 - Removes automatic default injection for downtimeMonitorStatuses and defaultBarColor fields in StatusPageService.onBeforeCreate() to fix Terraform provider "inconsistent result after apply" errors.

Problem

When creating a oneuptime_status_page resource via Terraform, the API automatically injects default values that weren't in the original request:

  • downtimeMonitorStatuses: Populated with all non-operational monitor statuses
  • defaultBarColor: Set to Green (#00ff00)

This causes Terraform validation to fail with:

Error: Provider produced inconsistent result after apply
.downtime_monitor_statuses: new element 0 has appeared

The status page is created successfully in OneUptime, but Terraform reports failure and doesn't add the resource to state.

Solution

Remove automatic default injection in Common/Server/Services/StatusPageService.ts (lines 144-174):

  • Removed downtimeMonitorStatuses default population (31 lines)
  • Removed defaultBarColor default injection (2 lines)
  • Cleaned up unused imports: MonitorStatusService, Green

UI Impact

None - All UI components already have fallback patterns:

Component Field Fallback
StatusPage/src/Pages/Overview/Overview.tsx downtimeMonitorStatuses `
StatusPage/src/Pages/Overview/Overview.tsx defaultBarColor `
Common/UI/Components/Graphs/DayUptimeGraph.tsx defaultBarColor `
Common/UI/Components/MonitorGraphs/Uptime.tsx downtimeMonitorStatuses `?.map(...)

Testing

Tested on local OneUptime instance (2026-01-19):

Before Fix:

terraform apply  # ❌ Failed: "Provider produced inconsistent result"

After Fix:

terraform apply   # ✅ Success - No inconsistent result error
terraform plan    # ✅ No changes - No state drift
terraform destroy # ✅ Clean removal

Test Results:

  • Status Page Created: test-customer (ID: a31779e2-2c66-4585-ae0f-a9b2b273ff81)
  • Terraform validation: Passed
  • State consistency: No drift detected
  • UI functionality: Uptime graphs display correctly with fallback colors

Relationship to PR #2231

This fix follows the exact same pattern as PR #2231 (Monitor default injection):

PR Resource Field Issue
#2231 Monitor monitor_steps.exceptionMonitor #2226
This PR StatusPage downtimeMonitorStatuses, defaultBarColor #2232

Both PRs:

  • Remove API-side default injection
  • Rely on UI fallbacks
  • Fix Terraform round-trip consistency
  • No breaking changes

Files Changed

  • Common/Server/Services/StatusPageService.ts (-36 lines)

Breaking Changes

None. Fields are nullable, and UI components already handle undefined values.


🤖 Generated with Claude Code

*Originally created by @listellm on 1/19/2026* ## Summary Fixes #2232 - Removes automatic default injection for `downtimeMonitorStatuses` and `defaultBarColor` fields in `StatusPageService.onBeforeCreate()` to fix Terraform provider "inconsistent result after apply" errors. ## Problem When creating a `oneuptime_status_page` resource via Terraform, the API automatically injects default values that weren't in the original request: - `downtimeMonitorStatuses`: Populated with all non-operational monitor statuses - `defaultBarColor`: Set to `Green` (#00ff00) This causes Terraform validation to fail with: ``` Error: Provider produced inconsistent result after apply .downtime_monitor_statuses: new element 0 has appeared ``` The status page is created successfully in OneUptime, but Terraform reports failure and doesn't add the resource to state. ## Solution Remove automatic default injection in `Common/Server/Services/StatusPageService.ts` (lines 144-174): - ✅ Removed `downtimeMonitorStatuses` default population (31 lines) - ✅ Removed `defaultBarColor` default injection (2 lines) - ✅ Cleaned up unused imports: `MonitorStatusService`, `Green` ## UI Impact **None** - All UI components already have fallback patterns: | Component | Field | Fallback | |-----------|-------|----------| | `StatusPage/src/Pages/Overview/Overview.tsx` | `downtimeMonitorStatuses` | `|| []` (5 usages) | | `StatusPage/src/Pages/Overview/Overview.tsx` | `defaultBarColor` | `|| Green` (2 usages) | | `Common/UI/Components/Graphs/DayUptimeGraph.tsx` | `defaultBarColor` | `|| Green` (2 usages) | | `Common/UI/Components/MonitorGraphs/Uptime.tsx` | `downtimeMonitorStatuses` | `?.map(...) || []` | ## Testing ✅ **Tested on local OneUptime instance** (2026-01-19): **Before Fix:** ```bash terraform apply # ❌ Failed: "Provider produced inconsistent result" ``` **After Fix:** ```bash terraform apply # ✅ Success - No inconsistent result error terraform plan # ✅ No changes - No state drift terraform destroy # ✅ Clean removal ``` **Test Results:** - Status Page Created: `test-customer` (ID: `a31779e2-2c66-4585-ae0f-a9b2b273ff81`) - Terraform validation: ✅ Passed - State consistency: ✅ No drift detected - UI functionality: ✅ Uptime graphs display correctly with fallback colors ## Relationship to PR #2231 This fix follows the **exact same pattern** as PR #2231 (Monitor default injection): | PR | Resource | Field | Issue | |----|----------|-------|-------| | #2231 | Monitor | `monitor_steps.exceptionMonitor` | #2226 | | **This PR** | **StatusPage** | **`downtimeMonitorStatuses`, `defaultBarColor`** | **#2232** | Both PRs: - Remove API-side default injection - Rely on UI fallbacks - Fix Terraform round-trip consistency - No breaking changes ## Files Changed - `Common/Server/Services/StatusPageService.ts` (-36 lines) ## Breaking Changes None. Fields are nullable, and UI components already handle undefined values. --- 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/oneuptime#153