slint-ui/slint · warning

Missing gradient stops for linear gradient

Error message

Missing gradient stops for linear gradient

What it means

getBrush found a GRADIENT_LINEAR paint that lacks gradientStops or gradientTransform, so no gradient can be generated. It warns and returns an empty string, producing a blank brush in the exported snippet.

Solutions

  1. Verify the gradient in Figma has at least one stop and a valid transform, then re-fetch the node
  2. Resolve gradient stops that are bound to color variables before calling getBrush
  3. Re-run export after refreshing the plugin's node data if the response was truncated
  4. Degrade gracefully to a solid color from the first available stop instead of returning ""

Example fix

// before
if (!fill.gradientStops || !fill.gradientTransform) { console.warn(...); return ""; }
// after
if (!fill.gradientStops?.length) {
  return fill.color ? rgbToHex(fill.color) : "transparent"; // degrade to solid
}
const transform = fill.gradientTransform ?? [[1,0,0],[0,1,0]];
Defensive patterns

Strategy: validation

Validate before calling

if (fill.type === "GRADIENT_LINEAR" && (!fill.gradientStops?.length || !fill.gradientTransform)) {
  throw new Error("Linear gradient missing stops or transform");
}

Type guard

function hasGradientData(fill: Paint): fill is GradientPaint & { gradientStops: ColorStop[]; gradientTransform: Transform } {
  return fill.type === "GRADIENT_LINEAR"
    && Array.isArray((fill as GradientPaint).gradientStops)
    && (fill as GradientPaint).gradientStops.length > 0
    && Array.isArray((fill as GradientPaint).gradientTransform);
}

Try / catch

try {
  brush = getBrush(fill);
} catch (e) {
  brush = firstStopColor(fill) ?? "transparent";
}

Prevention

When it happens

Trigger: getBrush handles a fill.type === 'GRADIENT_LINEAR' where fill.gradientStops or fill.gradientTransform is missing/empty.

Common situations: Gradient paint bound to variables/remote styles the plugin could not fetch; incomplete Figma REST/plugin response; a gradient created with zero stops (degenerate paint).

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of slint-ui/slint@bb937076de (2026-09-16). Data as JSON: /api/errors/3b34f806adadda51. Report an issue: GitHub.

Appendix: source

Thrown at tools/figma-inspector/backend/utils/property-parsing.ts:320

    gradientStops?: ReadonlyArray<{
        color: { r: number; g: number; b: number; a: number };
        position: number;
    }>;
    gradientTransform?: number[][];
}): string | null {
    const opacity = fill.opacity ?? 1; // Default to 1 if opacity is undefined

    switch (fill.type) {
        case "SOLID": {
            if (!fill.color) {
                console.warn("Missing fill colors for solid color value");
                return "";
            }
            return rgbToHex({ ...fill.color, a: opacity });
        }
        case "GRADIENT_LINEAR": {
            if (!fill.gradientStops || !fill.gradientTransform) {
                console.warn("Missing gradient stops for linear gradient");
                return "";
            }
            return generateLinearGradient({
                opacity: opacity,
                gradientStops: fill.gradientStops,
                gradientTransform: fill.gradientTransform,
            });
        }
        case "GRADIENT_RADIAL": {
            if (!fill.gradientStops || !fill.gradientTransform) {
                return "";
            }
            return generateRadialGradient({
                opacity: opacity,
                gradientStops: fill.gradientStops,
                gradientTransform: fill.gradientTransform,
            });
        }

View on GitHub (pinned to bb937076de)