Skip to content

Conversation

@akshatsinha0
Copy link
Contributor

Build sensitive_fields from copies to prevent bleed-through across requests/tests

SUMMARY
Build a local union set (set(base)|set(common)) in get_allowed_fields instead of updating SENSITIVE_FIELDS, preventing cross-request/type bleed-through and stabilizing MCP dataset/chart/dashboard filtering.

Call get_allowed_fields(...) and confirm SENSITIVE_FIELDS remains unchanged before/after.

• No UI changes; No DB migration; No new APIs...

Build sensitive_fields from copies to prevent bleed-through across requests/tests
@bito-code-review
Copy link
Contributor

bito-code-review bot commented Oct 31, 2025

Code Review Agent Run #58ce8e

Actionable Suggestions - 0
Review Details
  • Files reviewed - 1 · Commit Range: fa97954..fa97954
    • superset/mcp_service/utils/permissions_utils.py
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ 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 Default Agent 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 change:backend Requires changing the backend label Oct 31, 2025
@akshatsinha0
Copy link
Contributor Author

Please look here:-
@mistercrunch
@villebro
@kristw
@michael-s-molina

Copy link

@korbit-ai korbit-ai bot left a comment

Choose a reason for hiding this comment

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

Review by Korbit AI

Korbit automatically attempts to detect when you fix issues in new commits.
Category Issue Status
Design Redundant Set Conversion ▹ view
Files scanned
File Path Reviewed
superset/mcp_service/utils/permissions_utils.py

Explore our documentation to understand the languages and file types we support and the files we ignore.

Check out our docs on how you can make Korbit work best for you and your team.

Loving Korbit!? Share us on LinkedIn Reddit and X

Comment on lines +145 to +147
base=SENSITIVE_FIELDS.get(object_type, set())
common=SENSITIVE_FIELDS.get("common", set())
sensitive_fields= set(base)|set(common)
Copy link

Choose a reason for hiding this comment

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

Redundant Set Conversion category Design

Tell me more
What is the issue?

The code unnecessarily converts base and common to sets twice when they are already sets from SENSITIVE_FIELDS dictionary.

Why this matters

This creates unnecessary set conversions that impact performance and code clarity without adding any value.

Suggested change ∙ Feature Preview
base = SENSITIVE_FIELDS.get(object_type, set())
common = SENSITIVE_FIELDS.get("common", set())
sensitive_fields = base | common  # Set union operator directly on sets
Provide feedback to improve future suggestions

Nice Catch Incorrect Not in Scope Not in coding standard Other

💬 Looking for more details? Reply to this comment to chat with Korbit.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

:(

Copy link

Choose a reason for hiding this comment

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

I understand your disappointment. Let's focus on improving the code. Would you like to discuss the suggested change or explore alternative solutions?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes do that

Copy link

Choose a reason for hiding this comment

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

Understood. Let's consider these alternatives:

  1. Use set union directly:

    sensitive_fields = SENSITIVE_FIELDS.get(object_type, set()) | SENSITIVE_FIELDS.get("common", set())
  2. Use dict.get() with default empty set:

    sensitive_fields = SENSITIVE_FIELDS.get(object_type, set()) | SENSITIVE_FIELDS.get("common", set())
  3. Use dict.setdefault() to ensure sets:

    base = SENSITIVE_FIELDS.setdefault(object_type, set())
    common = SENSITIVE_FIELDS.setdefault("common", set())
    sensitive_fields = base | common

Which approach do you prefer, or do you have another idea?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ask for a review

@sadpandajoe
Copy link
Member

@aminghadersohi you might be interested in this PR as the person the added the MCP files

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 refactors how sensitive fields are computed in the get_allowed_fields function by changing from a mutable update pattern to an immutable set union operation.

  • Replaces in-place update() with set union operator | to combine sensitive fields
  • Introduces intermediate variables for base and common sensitive fields

Comment on lines +145 to +147
base=SENSITIVE_FIELDS.get(object_type, set())
common=SENSITIVE_FIELDS.get("common", set())
sensitive_fields= set(base)|set(common)
Copy link

Copilot AI Nov 4, 2025

Choose a reason for hiding this comment

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

Missing spaces around assignment operators. Python PEP 8 requires spaces around assignment operators. Change base= to base = , common= to common = , and sensitive_fields= to sensitive_fields = .

Suggested change
base=SENSITIVE_FIELDS.get(object_type, set())
common=SENSITIVE_FIELDS.get("common", set())
sensitive_fields= set(base)|set(common)
base = SENSITIVE_FIELDS.get(object_type, set())
common = SENSITIVE_FIELDS.get("common", set())
sensitive_fields = set(base) | set(common)

Copilot uses AI. Check for mistakes.
sensitive_fields.update(SENSITIVE_FIELDS.get("common", set()))
base=SENSITIVE_FIELDS.get(object_type, set())
common=SENSITIVE_FIELDS.get("common", set())
sensitive_fields= set(base)|set(common)
Copy link

Copilot AI Nov 4, 2025

Choose a reason for hiding this comment

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

Redundant set conversions. The .get(object_type, set()) calls already return sets, so wrapping them with set() again is unnecessary. Since base and common are already sets, use sensitive_fields = base | common directly.

Suggested change
sensitive_fields= set(base)|set(common)
sensitive_fields = base | common

Copilot uses AI. Check for mistakes.
@codecov
Copy link

codecov bot commented Nov 4, 2025

Codecov Report

❌ Patch coverage is 0% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 68.73%. Comparing base (fee4e7d) to head (fa97954).
⚠️ Report is 18 commits behind head on master.

Files with missing lines Patch % Lines
superset/mcp_service/utils/permissions_utils.py 0.00% 3 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           master   #35934       +/-   ##
===========================================
+ Coverage        0   68.73%   +68.73%     
===========================================
  Files           0      622      +622     
  Lines           0    45713    +45713     
  Branches        0     4972     +4972     
===========================================
+ Hits            0    31422    +31422     
- Misses          0    13046    +13046     
- Partials        0     1245     +1245     
Flag Coverage Δ
hive 44.21% <0.00%> (?)
mysql 67.81% <0.00%> (?)
postgres 67.86% <0.00%> (?)
presto 47.75% <0.00%> (?)
python 68.70% <0.00%> (?)
sqlite 67.47% <0.00%> (?)
unit 100.00% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@rusackas
Copy link
Member

CC @aminghadersohi but also...

Superset uses Git pre-commit hooks courtesy of pre-commit. To install run the following:

pip3 install -r requirements/development.txt
pre-commit install

A series of checks will now run when you make a git commit.

Alternatively it is possible to run pre-commit by running pre-commit manually:

pre-commit run --all-files

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

Labels

change:backend Requires changing the backend size/XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants