Repository navigation
fix(render): make graph functions work in non-cairo builds - #944
Merged
Merged
Conversation
Graph-only functions (color, stacked, threshold, verticalLine, holtWintersConfidenceArea, ...) were either silently returning no series or erroring in non-cairo builds, because their evaluation was gated behind the cairo build tag. The gating was only needed because types.GraphOptions was an empty struct without cairo. Make GraphOptions build-independent and unify the implementations: evaluation now behaves identically in both builds, with graph options simply ignored by data formats. Only PNG/SVG rendering remains behind the cairo tag.
Image formats previously returned an empty 200 body in binaries built without cairo (the Marshal stubs return nil). Fail fast with an explicit 501 and a clear message before any backend fetch.
Also point at the data formats in the error message, since png is the default format when none is specified.
The non-cairo variant now carries real behavior (graph function evaluation, the 501 render path) but was never built or tested in CI. The Makefile target already existed. A separate job keeps the e2e suite running against the cairo binary.
npazosmendez
force-pushed
the
njpm/nocairo-graph-functions
branch
from
August 10, 2026 18:39
31e5e29 to
6a71bc1
Compare
npazosmendez
marked this pull request as ready for review
August 10, 2026 19:04
carrieedwards
approved these changes
Aug 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Most Graphite Web's graph functions (
color(),threshold()etc) "work" with non-image formats (e.g.format=json) by being mostly no-op (depends on the function). For example, withcolor(randomWalk('a'), 'red'):This behavior is useful for two reasons: 1) some functions make sense even without image rendering (e.g.
threshold), 2) queries don't completely break when switching formatsCarbonapi follows that behavior, but only when built with
cairo. When built without cairo, they return no data (or an error in some cases).This PR changes that, and allows such functions to run correctly in no-cairo builds if possible. Only the image generation bit (which depends on the
format=requested) remains under the cairo build tag. If built without cairo, an error is returned, but only when an image is requested explicitly.Behavior changes:
color,stacked,areaBetween,alpha,dashed,drawAsInfinite,secondYAxis,lineWidth,threshold,verticalLineandholtWintersConfidenceAreanow evaluate normally and appear in/functions.format=png/svgreturns 501 instead of a 200 with an empty body. Notably, since png is the default format, requests withoutformatalso get 501 now.Other changes:
test_nocairoGraphOptionsstruct does not depend on the build tag,MetricDatatype size grows in no-cairo builds from 192 bytes to 272 bytes. I think this is acceptable and will probably be negligible compared to the memory that comes from tags and sample values. Still I wanted to state it explicitly