Skip to content

fix(core): fix the required session properties for CLAC#1287

Merged
douenergy merged 3 commits intoCanner:mainfrom
goldmedal:fix/clac-required-properties
Aug 20, 2025
Merged

fix(core): fix the required session properties for CLAC#1287
douenergy merged 3 commits intoCanner:mainfrom
goldmedal:fix/clac-required-properties

Conversation

@goldmedal
Copy link
Copy Markdown
Contributor

@goldmedal goldmedal commented Aug 15, 2025

I missed to pass the session propertes when construct the session cotnext. It leads to miss the properties for check the CLAC policy.

Summary by CodeRabbit

  • New Features
    • Session properties are now passed through and honored during query execution and shown in the local runner.
    • Column-level access control treats required property names case-insensitively and hides gated columns when unmet.
  • Bug Fixes
    • Improved, clearer error messages when manifest analysis fails.
  • Chores
    • Request headers are logged with sensitive values redacted.
  • Tests
    • Added tests covering case-insensitive required properties and RLAC behavior.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Aug 15, 2025

Walkthrough

Adds redacted request-header logging, threads session properties into local query runs and context creation, updates RLAC tests to verify case-insensitive requiredProperties and column gating, and changes MDL analysis to return detailed errors and use provided properties when creating execution context.

Changes

Cohort / File(s) Summary
Request logging headers
ibis-server/app/middleware/__init__.py
Logs incoming request headers with sensitive keys (authorization, proxy-authorization, cookie, set-cookie) redacted in RequestLogMiddleware.dispatch; other middleware behavior unchanged.
RLAC tests and case-insensitive requiredProperties
ibis-server/tests/routers/v3/connector/postgres/test_query.py
Adjusts manifest and bindings to test case-insensitive requiredProperties names; adds a base64-encoded manifest test posting a session_level header to validate column-level access control hides gated columns.
Local query runner session properties
ibis-server/tools/query_local_run.py
Adds a properties dict, prints session properties, and passes properties as a third argument to SessionContext(...).
Core context MDL analysis with properties
wren-core-py/src/context.rs
Replaces unwrap with match on AnalyzedWrenMDL::analyze(..., Mode::Unparse); on Ok wraps analyzed MDL and calls create_ctx_with_mdl with the provided properties, on Err returns CoreError with the MDL analysis error message.

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant ibis-server
  participant wren-core
  participant MDL_Analyzer
  participant ExecutionCtx

  Client->>ibis-server: Send query + headers (session properties)
  ibis-server->>ibis-server: Log method/path/body and redacted headers
  ibis-server->>wren-core: Create SessionContext(manifest, session, properties)
  wren-core->>MDL_Analyzer: analyze(manifest, properties, Unparse)
  alt Analysis OK
    MDL_Analyzer-->>wren-core: analyzed_mdl
    wren-core->>ExecutionCtx: create_ctx_with_mdl(analyzed_mdl, properties)
    ExecutionCtx-->>ibis-server: Execution result
    ibis-server-->>Client: 200 + data
  else Analysis Error
    MDL_Analyzer-->>wren-core: Error(e)
    wren-core-->>ibis-server: "Failed to analyze MDL: e"
    ibis-server-->>Client: Error response
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

core, rust

Suggested reviewers

  • douenergy

Poem

I twitch my ears at headers bright,
Redacted secrets tucked from sight.
Props hop in, the context wakes,
RLAC hides what it must take.
A rabbit smiles—no bugs tonight. 🐇✨

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between e0bca98 and b69cb6c.

📒 Files selected for processing (1)
  • ibis-server/app/middleware/__init__.py (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • ibis-server/app/middleware/init.py
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: test
  • GitHub Check: ci
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added ibis python Pull requests that update Python code labels Aug 15, 2025
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (3)
ibis-server/tools/query_local_run.py (1)

73-79: Session properties wiring looks good; consider sourcing from an env var for local runs.

Current code always passes an empty properties set. For local experimentation with CLAC/RLAC, reading from an env var (JSON) is convenient and avoids code edits.

Apply this diff to load properties from an optional JSON env var and normalize keys to lowercase:

-# Set the session properties here. It should be lowercase.
-properties =  {}
-properties = frozenset(properties.items())
-print("### Session Properties ###")
-for key, value in properties:
-    print(f"# {key}: {value}")
-session_context = SessionContext(encoded_str, function_list_path + f"/{data_source}.csv", properties)
+# Set the session properties here. Keys will be normalized to lowercase.
+# Optionally supply JSON via WREN_SESSION_PROPERTIES_JSON, e.g.:
+#   export WREN_SESSION_PROPERTIES_JSON='{"session_level":"2","session_user":"Customer#000000001"}'
+properties_json = os.getenv("WREN_SESSION_PROPERTIES_JSON")
+properties = json.loads(properties_json) if properties_json else {}
+properties = {str(k).lower(): (None if v is None else str(v)) for k, v in properties.items()}
+properties_fs = frozenset(properties.items())
+print("### Session Properties ###")
+for key, value in properties_fs:
+    print(f"# {key}: {value}")
+session_context = SessionContext(
+    encoded_str,
+    function_list_path + f"/{data_source}.csv",
+    properties_fs,
+)
wren-core-py/src/context.rs (1)

168-171: Outdated comment contradicts the new behavior; update or remove.

The comment says headers won’t be used and an empty map is provided, but you now pass the actual properties map to the context.

Apply this diff to correct the comment:

-                    // the headers won't be used in the context. Provide an empty map.
+                    // Use the provided session properties when creating the execution context.
ibis-server/tests/routers/v3/connector/postgres/test_query.py (1)

631-682: CLAC test with requiredProperties is solid; consider adding a negative case.

Great coverage for requiredProperties + case-insensitive names. Optionally, add a test where the required property is missing to verify the expected behavior (e.g., column hidden vs. explicit error), aligned with product/spec intent.

Would you like me to add a follow-up test asserting behavior when a required property is absent?

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 2f722ad and e0bca98.

📒 Files selected for processing (4)
  • ibis-server/app/middleware/__init__.py (1 hunks)
  • ibis-server/tests/routers/v3/connector/postgres/test_query.py (2 hunks)
  • ibis-server/tools/query_local_run.py (1 hunks)
  • wren-core-py/src/context.rs (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (3)
ibis-server/tests/routers/v3/connector/postgres/test_query.py (2)
ibis-server/tests/conftest.py (1)
  • client (18-23)
ibis-server/tests/routers/v3/connector/postgres/conftest.py (1)
  • connection_info (45-52)
wren-core-py/src/context.rs (4)
wren-core/core/src/mdl/mod.rs (4)
  • analyze (74-84)
  • mdl (195-224)
  • new (126-181)
  • new (529-531)
wren-core-base/manifest-macro/src/lib.rs (1)
  • manifest (26-56)
wren-core/core/src/mdl/context.rs (2)
  • new (339-361)
  • create_ctx_with_mdl (49-110)
wren-core-py/src/errors.rs (11)
  • new (17-21)
  • from (25-27)
  • from (31-33)
  • from (37-39)
  • from (43-45)
  • from (49-51)
  • from (55-64)
  • from (68-70)
  • from (74-76)
  • from (80-82)
  • from (86-88)
ibis-server/tools/query_local_run.py (2)
wren-core/core/src/mdl/context.rs (1)
  • properties (86-92)
wren-core/core/src/mdl/mod.rs (1)
  • data_source (318-320)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: ci
  • GitHub Check: test
🔇 Additional comments (2)
wren-core-py/src/context.rs (1)

161-176: Correctly analyze MDL with provided properties and propagate errors.

Good fix: you now analyze with the provided properties and pass them into the context, and you surface analyze errors instead of panicking.

Also applies to: 178-189

ibis-server/tests/routers/v3/connector/postgres/test_query.py (1)

102-107: Case-insensitive requiredProperties and variable usage covered—nice.

Renaming to "Session_user" and using "@session_User" increases confidence that name matching is case-insensitive.

@goldmedal goldmedal requested a review from douenergy August 15, 2025 10:04
@douenergy
Copy link
Copy Markdown
Contributor

Thanks @goldmedal

@douenergy douenergy merged commit 388a91a into Canner:main Aug 20, 2025
11 checks passed
nhaluc1005 pushed a commit to nhaluc1005/text2sql-practice that referenced this pull request Apr 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ibis python Pull requests that update Python code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants