Skip to content

fix: use unvalidated spec as fallback for canvas#9186

Merged
djbarnwal merged 2 commits intomainfrom
fix/canvas-unvalidated-spec
Apr 7, 2026
Merged

fix: use unvalidated spec as fallback for canvas#9186
djbarnwal merged 2 commits intomainfrom
fix/canvas-unvalidated-spec

Conversation

@djbarnwal
Copy link
Copy Markdown
Member

Previously, if any canvas component had an invalid spec, the entire canvas dashboard became inaccessible in Rill Developer because ResolveCanvas returned early when canvas.state.validSpec was nil. This broke the editing workflow where a user intentionally changes a metrics_view (causing a transient error state) before selecting the correct fields.

  • Fall back to the unvalidated spec in ResolveCanvas when validSpec is nil, so the canvas shell remains accessible during mid-edit error states
  • Apply the same fallback for component renderer properties in BaseChart, CanvasPivot, and BaseCanvasComponent
  • Fall back to spec.renderer when reading component type in canvas-entity.ts and BaseChart/CanvasPivot, fixing a blank inspector panel when clicking a broken component

The error/loading banner UX in CanvasInitialization.svelte is unchanged — it still uses validSpec to drive reconcile error messaging correctly. This matches the fallback pattern already used in ResolveTransitiveAccess (reconcilers/canvas.go:169-172).

Checklist:

  • Covered by tests
  • Ran it and it works as intended
  • Reviewed the diff before requesting a review
  • Checked for unhandled edge cases
  • Linked the issues it closes
  • Checked if the docs need to be updated. If so, create a separate Linear DOCS issue
  • Intend to cherry-pick into the release branch
  • I'm proud of this work!

@djbarnwal djbarnwal requested a review from begelundmuller April 4, 2026 12:08
Comment on lines +39 to +44
// Use the valid spec if available, otherwise fall back to the unvalidated spec.
// Falling back allows Rill Developer to keep the canvas accessible while the user is mid-edit.
spec := res.GetCanvas().State.ValidSpec
if spec == nil {
spec = res.GetCanvas().Spec
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels problematic because a) it means we may end up serving an invalid canvas in Rill Cloud, b) it may break features if we add rewriting logic in the canvas/component reconcilers in the future (like we have for metrics views and explores).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the visual editor needs this, can we guard it behind an unsafe bool parameter in the ResolveCanvasRequest payload? And then make sure unsafe is only sent by the visual editor, never in Rill Cloud and never by the readonly previews?

super(resource, parent, path, baseSpec as TConfig);

this.type = resource.component?.state?.validSpec?.renderer as ChartType;
this.type = (resource.component?.state?.validSpec?.renderer ??
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this code shared with readonly/cloud components? It's important that code that serves prod/readonly dashboards only ever read validSpec, never the raw spec (because we don't offer any guarantees about the spec, and may need to add rewriting logic at some later point, which would break code that relies on the unvalidated raw spec).

@djbarnwal djbarnwal requested a review from begelundmuller April 7, 2026 16:16
Copy link
Copy Markdown
Contributor

@begelundmuller begelundmuller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me :)

@djbarnwal djbarnwal merged commit 9a9175b into main Apr 7, 2026
23 of 26 checks passed
@djbarnwal djbarnwal deleted the fix/canvas-unvalidated-spec branch April 7, 2026 16:38
djbarnwal added a commit that referenced this pull request Apr 7, 2026
* fix: use unvalidated spec as fallback for canvas

* add unsafe bool for serving unvalidated spec
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants