Skip to content

fix(cubesql): Propagate errors from SqlAuthService to the user #9665

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

KSDaemon
Copy link
Member

@KSDaemon KSDaemon commented Jun 6, 2025

When using cube.py it’s fundamental to see errors and even better the stack trace of errors generated from python code, currently the logs doesn’t show any errors generated from python check_sql_auth.

This PR propagates such errors to the log.

Imaging this cube.py config:

# Validate the username and password of the user submitting the API request
@config('check_sql_auth')
def check_sql_auth(query: dict, username: str, password: str) -> dict:
  raise Exception('You should be able to see this error in the logs')

And let's try to connect to Cube via psql:

❯ psql -h 127.0.0.1 -p 15432 -U cube
psql: error: connection to server at "127.0.0.1", port 15432 failed: FATAL:  password authentication failed for user "cube"

And here is what we now can see in logs:

cubejs-server
🔥 Cube Store (1.3.19) is assigned to 3030 port.
🔓 Authentication checks are disabled in developer mode. Please use NODE_ENV=production to enable it.
🦅 Dev environment available at http://localhost:4000
🔗 Cube SQL (pg) is listening on 0.0.0.0:15432
🚀 Cube API server (1.3.19) is listening on 4000
Auth Error: undefined
{}
Error: Python error: Exception: You should be able to see this error in the logs
Traceback (most recent call last):
  File "cube.py", line 14, in check_sql_auth
    raise Exception('You should be able to see this error in the logs')

Check List

  • Tests have been run in packages where changes made if available
  • Linter has been run for changed code
  • Tests for the changes have been added if not covered yet

Copy link

codecov bot commented Jun 6, 2025

Codecov Report

Attention: Patch coverage is 18.18182% with 9 lines in your changes missing coverage. Please review.

Project coverage is 84.17%. Comparing base (91d57de) to head (4799615).

Files with missing lines Patch % Lines
...ubesql/cubesql/src/sql/postgres/pg_auth_service.rs 18.18% 9 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           master    #9665       +/-   ##
===========================================
+ Coverage        0   84.17%   +84.17%     
===========================================
  Files           0      230      +230     
  Lines           0    85114    +85114     
===========================================
+ Hits            0    71647    +71647     
- Misses          0    13467    +13467     
Flag Coverage Δ
cubesql 84.17% <18.18%> (?)

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.

@KSDaemon KSDaemon marked this pull request as ready for review June 6, 2025 11:16
@KSDaemon KSDaemon requested a review from a team as a code owner June 6, 2025 11:16
@KSDaemon KSDaemon force-pushed the fix/propagate-error branch from 4799615 to 894901e Compare June 6, 2025 13:34
@KSDaemon KSDaemon requested a review from a team as a code owner June 6, 2025 13:34
@KSDaemon KSDaemon requested a review from ovr June 6, 2025 13:46
skipPasswordCheck,
};
} catch (e) {
this.apiGateway.log({
Copy link
Member

@ovr ovr Jun 9, 2025

Choose a reason for hiding this comment

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

It's just another problem related to how users write check_sql_auth.

Default example from the documentation:
https://cube.dev/docs/product/configuration/reference/config#check_sql_auth

It will throw an exception for incorrect username/password, but the biggest problem is that we will start to spam it in our logs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants