Skip to content

Invoke __identity_connected__ for sql http requests #2826

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 2 commits into
base: master
Choose a base branch
from

Conversation

mamcx
Copy link
Contributor

@mamcx mamcx commented Jun 4, 2025

Description of Changes

Closes #2802

We invoke identity_connected for reducer calls over http but not for sql. This is a problem since identity_connected can have access control logic.

API and ABI breaking changes

Minor: It will run the on_connect and on_disconnect so in could reject calls that before run.

Expected complexity level and risk

1

Testing

  • Add smoke test

@mamcx mamcx self-assigned this Jun 4, 2025
@mamcx mamcx added release-any To be landed in any release window api-break A PR that makes an API breaking change labels Jun 4, 2025
@mamcx mamcx requested a review from coolreader18 June 4, 2025 16:18
Comment on lines 413 to 453
.leader(database.id)
.await
.map_err(log_and_500)?
.ok_or(StatusCode::NOT_FOUND)?;
let json = host.exec_sql(auth, database, body).await?;
let json = leader.exec_sql(auth, database, body).await?;

let total_duration = json.iter().fold(0, |acc, x| acc + x.total_duration_micros);

call_on_disconnect(module, connection_id, caller_identity).await?;

Copy link
Collaborator

Choose a reason for hiding this comment

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

You shouldn't ? on the result from exec_sql until after you call call_on_disconnect; otherwise, if the query fails for any reason, the module will never know that the client has disconnected. probably want something like

let json_result = exec_sql.await;
let disconn_result = call_on_disconnect.await;
let json = json_result?;
disconn_result?;

But that precise order of a sql error taking precedence over an on_disconnect error probably doesn't matter too much

@mamcx mamcx force-pushed the mamcx/invoke-identity-connected-sql branch 3 times, most recently from 94b95fe to 5a43886 Compare June 6, 2025 15:46
@mamcx mamcx force-pushed the mamcx/invoke-identity-connected-sql branch from dfd8eb1 to 44ce625 Compare June 6, 2025 16:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-break A PR that makes an API breaking change release-any To be landed in any release window
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Invoke __identity_connected__ for sql http requests
2 participants