plandex-ai/plandex · error

Error marshalling projects:

Error message

Error marshalling projects: 

What it means

After scanning all rows, the handler marshals the []shared.Project slice with encoding/json. Like error 1042, this is defensive: marshalling a slice of structs with string fields cannot realistically fail. If triggered, the handler returns 500 with the marshal error.

Source

Thrown at app/server/handlers/projects.go:116

	}

	var projects []shared.Project

	for rows.Next() {
		var project shared.Project
		err := rows.Scan(&project.Id, &project.Name)
		if err != nil {
			log.Printf("Error scanning project: %v\n", err)
			http.Error(w, "Error scanning project: "+err.Error(), http.StatusInternalServerError)
			return
		}
		projects = append(projects, project)
	}

	bytes, err := json.Marshal(projects)
	if err != nil {
		log.Printf("Error marshalling projects: %v\n", err)
		http.Error(w, "Error marshalling projects: "+err.Error(), http.StatusInternalServerError)
		return
	}

	w.Write(bytes)
}

func ProjectSetPlanHandler(w http.ResponseWriter, r *http.Request) {
	log.Println("Received request for UpdateProjectSetPlanHandler")
	auth := Authenticate(w, r, true)
	if auth == nil {
		return
	}

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

	log.Println("projectId: ", projectId)

View on GitHub (pinned to e2d772072e)

Solutions

  1. Read the appended err.Error() to identify the offending field.
  2. Inspect recent changes to shared.Project for unsupported field types or faulty MarshalJSON implementations.
  3. Fix the struct (supported type or proper MarshalJSON) and rebuild.
  4. Add a serialization unit test for shared.Project.
Defensive patterns

Strategy: try-catch

Try / catch

body, err := io.ReadAll(res.Body)
if err != nil {
	return err
}
if res.StatusCode == http.StatusInternalServerError && strings.Contains(string(body), "Error marshalling projects") {
	return fmt.Errorf("server serialization bug: %s", string(body))
}
var projects []shared.Project
return json.Unmarshal(body, &projects)

Prevention

When it happens

Trigger: Practically unreachable with the current shared.Project (Id, Name strings); would require the struct to gain unmarshalable fields (channels, funcs, cyclic pointers) or invalid UTF-8-only cases json can still encode.

Common situations: Seeing this implies a recent change to shared.Project adding a field of unsupported type, or a custom MarshalJSON method returning an error.

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/e76bbe462ddc5f14. Report an issue: GitHub.