plandex-ai/plandex · error · http

Error marshalling settings

Error message

Error marshalling settings

What it means

After successfully loading settings, GetSettingsHandler serializes them with json.Marshal. If marshaling fails, the handler returns HTTP 500 'Error marshalling settings'. In practice this is rare because the settings structure is JSON-serializable, but it can happen with invalid state such as unsupported types or values injected into the settings object.

Source

Thrown at app/server/handlers/settings.go:71

			return err
		}

		settings = res

		return nil
	})

	if err != nil {
		log.Println("Error getting settings: ", err)
		http.Error(w, "Error getting settings", http.StatusInternalServerError)
		return
	}

	bytes, err := json.Marshal(settings)

	if err != nil {
		log.Println("Error marshalling settings: ", err)
		http.Error(w, "Error marshalling settings", http.StatusInternalServerError)
		return
	}

	log.Println("GetSettingsHandler processed successfully")

	w.Write(bytes)
}

func UpdateSettingsHandler(w http.ResponseWriter, r *http.Request) {
	log.Println("Received request for UpdateSettingsHandler")

	auth := Authenticate(w, r, true)
	if auth == nil {
		return
	}

	vars := mux.Vars(r)
	planId := vars["planId"]

View on GitHub (pinned to e2d772072e)

Solutions

  1. Ensure all fields of the settings struct are JSON-serializable types
  2. Remove or handle cycles and non-finite numbers before marshaling
  3. Add a MarshalJSON method for any custom types in the settings schema
  4. Pin server and client versions so the settings schema matches

Example fix

// before
bytes, err := json.Marshal(settings)
// after
safe := toSerializableSettings(settings)
bytes, err := json.Marshal(safe)
Defensive patterns

Strategy: fallback

Try / catch

resp, err := client.GetSettings(ctx)
if err != nil {
    // 500 'Error marshalling settings': treat as server bug
    return defaultSettings, nil
}

Prevention

When it happens

Trigger: json.Marshal(settings) fails: settings contain an unsupported Go type (e.g. func, chan), a cyclic structure, or an invalid value (NaN/Inf float) introduced when settings were loaded or mutated.

Common situations: A custom/modified settings struct added an unserializable field; settings data constructed from dynamic/untyped sources contains cycles or bad floats; version mismatch where new fields were never made JSON-safe.

Understand the failure class

Background: json.Marshal / "failed to marshal" errors in Go: why "unsupported type" happens and how to fix it — this error's family across 22 libraries.

Related errors


AI-assisted analysis of plandex-ai/plandex@e2d772072e (2026-09-05). Data as JSON: /api/errors/268841966476355f. Report an issue: GitHub.