Skip to content

Conversation

@VinayaKumar12
Copy link

fix(charts): normalize server_page_length from string to number

SUMMARY

Fixes a backend type comparison error ('<' not supported between instances of 'str' and 'int') that occurs when using custom server page length values in Table charts.

The SelectControl component with freeForm: true stores user-typed values as strings. When server_page_length is manually entered (e.g., "99"), it's saved as a string but the Python backend expects a number for comparison operations.

This PR adds type normalization in exploreReducer.js to convert server_page_length from string to number when the SET_FIELD_VALUE action is dispatched. The fix is targeted - only server_page_length is normalized, as other controls like row_limit don't exhibit this backend issue.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Before:

  • Screenshot showing the error: "Error loading chart datasources. Filters may not work correctly."
image image
  • Backend console error: TypeError: '<' not supported between instances of 'str' and 'int'
image

After:

  • Screenshot showing the chart loads successfully with custom server page length value
image image

TESTING INSTRUCTIONS

  1. Create or open a Table chart
  2. In the "Data" tab, expand "Server Pagination" section
  3. Enable "Server Pagination" toggle
  4. Manually type a custom value in "Server Page Length" field (e.g., 99)
  5. Click "Update Chart"
  6. Verify the chart loads successfully without backend errors
  7. Run unit tests: cd superset-frontend && npm test -- exploreReducer.test.js

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

Fixes backend type comparison error where SelectControl with freeForm
stores values as strings. Added normalization in exploreReducer for
server_page_length control.
@bito-code-review
Copy link
Contributor

bito-code-review bot commented Jan 28, 2026

Code Review Agent Run #7c4137

Actionable Suggestions - 0
Additional Suggestions - 2
  • superset-frontend/src/explore/reducers/exploreReducer.test.js - 1
    • Incomplete test coverage for edge case · Line 47-82
      The added tests verify normalization for '100' but overlook '0', which exposes a flaw in the reducer where Number('0') || '0' incorrectly retains the string due to 0 being falsy. This could lead to unexpected string values in form_data.server_page_length.
      Code suggestion
       @@ -82,1 +82,13 @@
      -});
      +});
      +
      +test('normalizes server_page_length from string "0" to number 0', () => {
      +  const initialState = {
      +    form_data: { viz_type: 'table' },
      +    controls: {},
      +  };
      +
      +  const action = setControlValue('server_page_length', '0');
      +  const newState = exploreReducer(initialState, action);
      +
      +  expect(newState.form_data.server_page_length).toBe(0);
      +  expect(typeof newState.form_data.server_page_length).toBe('number');
      +});
  • superset-frontend/src/explore/reducers/exploreReducer.js - 1
    • Comment spelling correction · Line 248-248
      The comment uses 'dependant', a less common variant; 'dependent' is preferred in American English and matches standard spelling.
      Code suggestion
       @@ -249,1 +249,1 @@
      -              // Re run validation for dependant controls
      +              // Re run validation for dependent controls
Review Details
  • Files reviewed - 2 · Commit Range: 5060118..5060118
    • superset-frontend/src/explore/reducers/exploreReducer.js
    • superset-frontend/src/explore/reducers/exploreReducer.test.js
  • Files skipped - 0
  • Tools
    • Eslint (Linter) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

@dosubot dosubot bot added the explore Namespace | Anything related to Explore label Jan 28, 2026
@netlify
Copy link

netlify bot commented Jan 28, 2026

Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 5060118
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6979cf6c7aca7d000815250f
😎 Deploy Preview https://deploy-preview-37517--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@VinayaKumar12
Copy link
Author

/review

@bito-code-review
Copy link
Contributor

bito-code-review bot commented Jan 28, 2026

Code Review Agent Run #95cc7d

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: 5060118..8911d2d
    • superset-frontend/src/explore/reducers/exploreReducer.js
    • superset-frontend/src/explore/reducers/exploreReducer.test.js
  • Files skipped - 0
  • Tools
    • Eslint (Linter) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

@bito-code-review
Copy link
Contributor

bito-code-review bot commented Jan 28, 2026

Code Review Agent Run #f27707

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: 5060118..8911d2d
    • superset-frontend/src/explore/reducers/exploreReducer.js
    • superset-frontend/src/explore/reducers/exploreReducer.test.js
  • Files skipped - 0
  • Tools
    • Eslint (Linter) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a backend type comparison error that occurs when using custom server page length values in Table charts. The issue arises because the SelectControl component with freeForm: true stores user-typed values as strings, but the Python backend expects numeric values for comparison operations.

Changes:

  • Adds type normalization in the SET_FIELD_VALUE action handler to convert server_page_length from string to number
  • Implements targeted normalization that only affects server_page_length, preserving existing behavior for other controls
  • Adds comprehensive unit tests to verify the normalization behavior

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
superset-frontend/src/explore/reducers/exploreReducer.js Adds normalization logic to convert server_page_length from string to number when the value is set, while preserving invalid strings for validation
superset-frontend/src/explore/reducers/exploreReducer.test.js Adds test cases covering string-to-number conversion, numeric value preservation, non-normalization of other controls, and edge case handling for '0'

Comment on lines 127 to 129
// Normalize server_page_length to number if it's a string
const normalizedValue =
controlName === 'server_page_length' && typeof value === 'string'
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

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

The normalization logic converts an empty string to the number 0, which may not be the intended behavior. Consider whether an empty string should be preserved for validation or converted to 0. If empty strings should remain for validation to catch, the logic should check for empty strings before conversion:

controlName === 'server_page_length' && typeof value === 'string' && value.trim() !== '' ? (isNaN(Number(value)) ? value : Number(value)) : value

This would align with the validateInteger function which checks v.trim().length > 0 before validation.

Suggested change
// Normalize server_page_length to number if it's a string
const normalizedValue =
controlName === 'server_page_length' && typeof value === 'string'
// Normalize server_page_length to number if it's a non-empty string
const normalizedValue =
controlName === 'server_page_length' &&
typeof value === 'string' &&
value.trim() !== ''

Copilot uses AI. Check for mistakes.
@pull-request-size pull-request-size bot added size/L and removed size/M labels Jan 29, 2026
@bito-code-review
Copy link
Contributor

bito-code-review bot commented Jan 29, 2026

Code Review Agent Run #fc04b0

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: 8911d2d..a1648f4
    • superset-frontend/src/explore/reducers/exploreReducer.js
    • superset-frontend/src/explore/reducers/exploreReducer.test.js
  • Files skipped - 0
  • Tools
    • Eslint (Linter) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

explore Namespace | Anything related to Explore size/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant