fix: Remove automatic default injection in MonitorStep.fromJSON #155

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

Originally created by @listellm on 1/17/2026

Summary

  • 🔧 Remove automatic population of logMonitor, traceMonitor, metricMonitor, exceptionMonitor defaults in fromJSON() method
  • 🐛 Fixes Terraform provider "inconsistent result after apply" errors
  • 📝 API was injecting defaults not present in original request, breaking round-trip consistency

Problem

When creating monitors via the Terraform provider, the API response included default values for optional fields (exceptionMonitor, logMonitor, etc.) that were not present in the original request. This caused Terraform to report:

Provider produced inconsistent result after apply

.monitor_steps: was cty.StringVal("...no exceptionMonitor...")
but now cty.StringVal("...\"exceptionMonitor\":{\"exceptionTypes\":[],...}...")

Root Cause

Common/Types/Monitor/MonitorStep.ts lines 451-467 explicitly injected defaults during JSON deserialisation:

if (monitorStep.data && !monitorStep.data?.exceptionMonitor) {
  monitorStep.data.exceptionMonitor = MonitorStepExceptionMonitorUtil.getDefault();
}

Solution

Removed the automatic default injection blocks in fromJSON(). The fields remain undefined when not provided, preserving round-trip consistency.

Testing

  • Monitor creation succeeds without "inconsistent result" error
  • No state drift on re-plan (No changes. Your infrastructure matches the configuration.)
  • Dashboard uses fallback patterns at render time (unaffected)
  • Worker validates presence explicitly (unchanged behaviour)

Test Plan

  • Verified fix with local OneUptime instance
  • Terraform apply/plan cycle produces consistent state
  • Published provider v9.3.22 works with this fix (server-side only change)

Fixes #2226

🤖 Generated with Claude Code

*Originally created by @listellm on 1/17/2026* ## Summary - 🔧 Remove automatic population of `logMonitor`, `traceMonitor`, `metricMonitor`, `exceptionMonitor` defaults in `fromJSON()` method - 🐛 Fixes Terraform provider "inconsistent result after apply" errors - 📝 API was injecting defaults not present in original request, breaking round-trip consistency ## Problem When creating monitors via the Terraform provider, the API response included default values for optional fields (`exceptionMonitor`, `logMonitor`, etc.) that were not present in the original request. This caused Terraform to report: ``` Provider produced inconsistent result after apply .monitor_steps: was cty.StringVal("...no exceptionMonitor...") but now cty.StringVal("...\"exceptionMonitor\":{\"exceptionTypes\":[],...}...") ``` ## Root Cause `Common/Types/Monitor/MonitorStep.ts` lines 451-467 explicitly injected defaults during JSON deserialisation: ```typescript if (monitorStep.data && !monitorStep.data?.exceptionMonitor) { monitorStep.data.exceptionMonitor = MonitorStepExceptionMonitorUtil.getDefault(); } ``` ## Solution Removed the automatic default injection blocks in `fromJSON()`. The fields remain `undefined` when not provided, preserving round-trip consistency. ## Testing - ✅ Monitor creation succeeds without "inconsistent result" error - ✅ No state drift on re-plan (`No changes. Your infrastructure matches the configuration.`) - ✅ Dashboard uses fallback patterns at render time (unaffected) - ✅ Worker validates presence explicitly (unchanged behaviour) ## Test Plan - [x] Verified fix with local OneUptime instance - [x] Terraform apply/plan cycle produces consistent state - [x] Published provider v9.3.22 works with this fix (server-side only change) Fixes #2226 🤖 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#155