{"record":{"id":"f6a415747adbe368","repo":"makeplane/plane","slug":"invalid-y-axis-value-y-axis","errorCode":null,"errorMessage":"Invalid y_axis value: {y_axis}","messagePattern":"Invalid y_axis value: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"apps/api/plane/utils/analytics_plot.py","lineNumber":77,"sourceCode":"        return queryset, \"dimension\"\n    else:\n        return queryset.annotate(dimension=F(x_axis)), \"dimension\"\n\n\ndef sort_data(data, temp_axis):\n    # When the axis is in priority order by\n    if temp_axis == \"priority\":\n        order = [\"low\", \"medium\", \"high\", \"urgent\", \"none\"]\n        return {key: data[key] for key in order if key in data}\n    else:\n        return dict(sorted(data.items(), key=lambda x: (x[0] == \"none\", x[0])))\n\n\ndef build_graph_plot(queryset, x_axis, y_axis, segment=None):\n    if x_axis not in VALID_ANALYTICS_FIELDS:\n        raise ValueError(f\"Invalid x_axis value: {x_axis}\")\n    if y_axis not in VALID_YAXIS:\n        raise ValueError(f\"Invalid y_axis value: {y_axis}\")\n    if segment and segment not in VALID_ANALYTICS_FIELDS:\n        raise ValueError(f\"Invalid segment value: {segment}\")\n\n    # temp x_axis\n    temp_axis = x_axis\n    # Extract the x_axis and queryset\n    queryset, x_axis = extract_axis(queryset, x_axis)\n    if x_axis == \"dimension\":\n        queryset = queryset.exclude(dimension__isnull=True)\n\n    #\n    if segment in [\"created_at\", \"start_date\", \"target_date\", \"completed_at\"]:\n        queryset = annotate_with_monthly_dimension(queryset, segment, \"segmented\")\n        segment = \"segmented\"\n\n    queryset = queryset.values(x_axis)\n\n    # Issue count","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/makeplane/plane/blob/1c8a60f858d8472aa56e29994ec1c7926da2c6ce/apps/api/plane/utils/analytics_plot.py#L59-L95","documentation":"ValueError raised by `build_graph_plot` (analytics_plot.py:76) when `y_axis` is not in `VALID_YAXIS`, which contains exactly two values: `issue_count` and `estimate`. Any other y_axis string (including the UPPERCASE `WORK_ITEM_COUNT` used by build_chart, or typos like `issue_count`) triggers it.","triggerScenarios":"Calling build_graph_plot with y_axis other than 'issue_count' or 'estimate'. The HTTP AnalyticsEndpoint guards this and returns 400 first, so the raw ValueError surfaces in the export bgtask or direct internal callers.","commonSituations":"Mixing the two analytics APIs: build_chart uses UPPERCASE y-axis 'WORK_ITEM_COUNT' while analytics_plot uses lowercase 'issue_count'; passing 'estimate' when the project has no estimate system enabled; typos.","solutions":["Pass exactly 'issue_count' or 'estimate' (lowercase) for y_axis.","Do not pass build_chart's 'WORK_ITEM_COUNT' to analytics_plot - translate it to 'issue_count'.","Validate y_axis against VALID_YAXIS before the call in bgtasks/tests.","Confirm the workspace has estimates configured if you pass 'estimate', otherwise the resulting data may be empty."],"exampleFix":"# before\nbuild_graph_plot(qs, x_axis=\"priority\", y_axis=\"WORK_ITEM_COUNT\")\nbuild_graph_plot(qs, x_axis=\"priority\", y_axis=\"count\")\n\n# after\nbuild_graph_plot(qs, x_axis=\"priority\", y_axis=\"issue_count\")","handlingStrategy":"validation","validationCode":"from plane.utils.analytics_plot import VALID_YAXIS\n\ndef is_valid_y_axis(y_axis: str) -> bool:\n    # VALID_YAXIS is exactly ['issue_count', 'estimate']\n    return y_axis in VALID_YAXIS","typeGuard":"from plane.utils.analytics_plot import VALID_YAXIS\n\ndef is_valid_y_axis(value: str) -> bool:\n    return isinstance(value, str) and value in VALID_YAXIS","tryCatchPattern":"try:\n    dist = build_graph_plot(qs, x_axis, y_axis, segment)\nexcept ValueError as e:\n    if 'Invalid y_axis' in str(e):\n        return bad_request(str(e))","preventionTips":["Only 'issue_count' and 'estimate' are valid y_axis values.","Translate build_chart's 'WORK_ITEM_COUNT' to 'issue_count'.","Confirm estimates are configured before passing 'estimate'."],"tags":["analytics","validation","value-error","api"],"backgroundTag":null,"analyzedSha":"1c8a60f858d8472aa56e29994ec1c7926da2c6ce","analyzedAt":"2026-08-12T14:44:31.636Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}