Skip to content

fix(semantic_layers): mask write-only config fields, gate flag-off endpoints - #43474

Open
rusackas wants to merge 4 commits into
masterfrom
fix/semantic-layer-parity-followup
Open

fix(semantic_layers): mask write-only config fields, gate flag-off endpoints#43474
rusackas wants to merge 4 commits into
masterfrom
fix/semantic-layer-parity-followup

Conversation

@rusackas

Copy link
Copy Markdown
Member

SUMMARY

Two follow-ups on the semantic-layer/theme access-check work from #43389, for consistency:

  • _serialize_layer's configuration blob is now passed through a masking step before it's returned. A connector publishes its configuration shape via get_configuration_schema; any property marked "writeOnly": true (the standard JSON Schema way of flagging a field that's set but never echoed back, e.g. a password or API key) gets replaced with the same PASSWORD_MASK used elsewhere in the codebase, rather than returned as-is.
  • get_list, get, and runtime_schema now carry the same SEMANTIC_LAYERS feature-flag guard that structure, views, and delete already have, so the flag gating is consistent across the whole API surface.

Behavior is unchanged for connectors that don't mark any config field writeOnly.

TESTING INSTRUCTIONS

pytest tests/unit_tests/semantic_layers/ — new unit tests for _mask_configuration (redacts marked fields, leaves unset/falsy values alone, no-ops when there's no registered connector or the schema can't be loaded) and for the three new feature-flag guards (both through the client and via direct unwrapped calls, matching the existing pattern for the other guarded endpoints).

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration
  • Introduces new feature or API
  • Removes existing feature or API

…dpoints

_serialize_layer now redacts configuration properties a connector's
get_configuration_schema marks writeOnly, mirroring PASSWORD_MASK usage
elsewhere. get_list, get, and runtime_schema now carry the same
SEMANTIC_LAYERS feature-flag guard already present on structure/views/delete.
@dosubot dosubot Bot added the api Related to the REST API label Aug 24, 2026
Comment thread superset/semantic_layers/api.py Outdated
@bito-code-review

Copy link
Copy Markdown
Contributor

The security concern is valid. In the current implementation of _mask_configuration, if get_configuration_schema() raises an exception, the function catches it and returns the original, unmasked configuration. This means that if the schema cannot be loaded, the system fails open, potentially exposing sensitive credentials.

To resolve this, the function should fail closed by raising an exception or returning an empty/masked configuration when the schema cannot be retrieved. Here is a corrected implementation:

    try:
        schema = cls.get_configuration_schema()
    except Exception:
        # Fail closed: return an empty configuration or raise an error
        return {}

I have checked the available PR comments, and there are no other pending review comments to address. Would you like me to proceed with any other changes?

superset/semantic_layers/api.py

try:
        schema = cls.get_configuration_schema()
    except Exception:
        # Fail closed: return an empty configuration or raise an error
        return {}

@bito-code-review bito-code-review Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review Agent Run #124a5d

Actionable Suggestions - 1
  • superset/semantic_layers/api.py - 1
Additional Suggestions - 2
  • tests/unit_tests/semantic_layers/api_test.py - 1
    • Missing test coverage for connections · Line 2653-2682
      The `connections()` endpoint at api.py:1024 also has `is_feature_enabled("SEMANTIC_LAYERS")` guard that returns 404 when disabled. No corresponding test exists for this method.
  • superset/semantic_layers/api.py - 1
    • Masking bypass for empty-string write-only values · Line 112-112
      The condition `and value` in the dict comprehension on line 112 silently skips masking for empty-string secret fields (e.g., `"password": ""`). While this matches the unit test at `api_test.py:1187`, it creates a subtle data-loss path: an empty string in the request body will be preserved in the response, leaking information about which fields are write-only. The comment `leaves an unset write-only field alone` implies a deliberate design choice, but the resulting response `{password: ""}` on a field marked `writeOnly` is indistinguishable from a typo or misconfiguration.
Review Details
  • Files reviewed - 2 · Commit Range: f67f6d8..f67f6d8
    • superset/semantic_layers/api.py
    • tests/unit_tests/semantic_layers/api_test.py
  • Files skipped - 0
  • Tools
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ 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 an incremental AI Review.

  • /review full - 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

Comment thread superset/semantic_layers/api.py
@codecov

codecov Bot commented Aug 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.97%. Comparing base (f3142e7) to head (c5f2543).
⚠️ Report is 78 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #43474      +/-   ##
==========================================
+ Coverage   78.90%   78.97%   +0.07%     
==========================================
  Files        2878     2878              
  Lines      165031   165555     +524     
  Branches    38135    38252     +117     
==========================================
+ Hits       130218   130748     +530     
+ Misses      32363    32321      -42     
- Partials     2450     2486      +36     
Flag Coverage Δ
hive 37.94% <0.00%> (-0.11%) ⬇️
mysql 57.68% <0.00%> (-0.13%) ⬇️
postgres 57.71% <0.00%> (-0.13%) ⬇️
presto 39.86% <0.00%> (-0.12%) ⬇️
python 83.68% <100.00%> (+0.11%) ⬆️
sqlite 57.40% <0.00%> (-0.13%) ⬇️
unit 73.79% <100.00%> (+0.17%) ⬆️

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

☔ View full report in Codecov by Harness.
📢 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.

… missing coverage test

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@netlify

netlify Bot commented Aug 24, 2026

Copy link
Copy Markdown

Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit a166962
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6a8caf1dd2b8e7000886053f
😎 Deploy Preview https://deploy-preview-43474--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

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

@bito-code-review

bito-code-review Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #f8c9a6

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: f67f6d8..a166962
    • superset/semantic_layers/api.py
    • tests/unit_tests/semantic_layers/api_test.py
  • Files skipped - 0
  • Tools
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ 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 an incremental AI Review.

  • /review full - 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

Comment thread superset/semantic_layers/api.py Outdated
Comment thread superset/semantic_layers/api.py
Address two review findings: a missing/unregistered connector class
made _mask_configuration a no-op instead of failing closed like the
schema-load-error path, and UpdateSemanticLayerCommand wrote a
round-tripped PASSWORD_MASK sentinel straight back into storage,
overwriting the real stored credential on a name-only edit.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@bito-code-review

bito-code-review Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #ebc696

Actionable Suggestions - 0
Review Details
  • Files reviewed - 4 · Commit Range: a166962..8ccdbc9
    • superset/commands/semantic_layer/update.py
    • superset/semantic_layers/api.py
    • tests/unit_tests/commands/semantic_layer/update_test.py
    • tests/unit_tests/semantic_layers/api_test.py
  • Files skipped - 0
  • Tools
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ 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 an incremental AI Review.

  • /review full - 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

Comment thread superset/commands/semantic_layer/update.py Outdated
…t just write-only ones

Once a GET fell back to masking every value (schema unavailable at read
time), the update path only restored write-only keys, so a name-only save
could persist the literal mask into non-secret fields like `account` once
the schema became available again.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@bito-code-review

bito-code-review Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #59ae53

Actionable Suggestions - 0
Additional Suggestions - 1
  • tests/unit_tests/commands/semantic_layer/update_test.py - 1
    • Missing edge case coverage · Line 534-548
      Deleted `test_unmask_configuration_schema_error` test was the only coverage for the fail-closed edge case where existing configuration cannot be parsed. The new implementation (lines 67-72) silently defaults to `{}` on parse errors, which is valid behavior, but this specific path is no longer exercised by any remaining test.
Review Details
  • Files reviewed - 2 · Commit Range: 8ccdbc9..c5f2543
    • superset/commands/semantic_layer/update.py
    • tests/unit_tests/commands/semantic_layer/update_test.py
  • Files skipped - 0
  • Tools
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ 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 an incremental AI Review.

  • /review full - 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

api Related to the REST API preset-io size/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants