[backend:fix] fix interactive and portal publish PythonUDF MCDB-100138 #closes - #138
Conversation
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Registration can leave partial or stale SQL definitions pointing to an unavailable endpoint.
Review effort: Balanced
Findings: 2
Open (2)
What changed in this PR
Prevents interactive notebook sessions from overwriting published or other-session Python UDF registrations.
Changes:
- Adds service URL parsing and ownership classification.
- Introduces ownership-aware interactive registration.
- Adds unit tests and registration logging.
| File | Description |
|---|---|
singlestoredb/functions/ext/function_url.py |
Adds URL parsing and classification helpers. |
singlestoredb/functions/ext/asgi.py |
Implements interactive registration safeguards. |
singlestoredb/apps/_python_udfs.py |
Uses the new registration path and logs names. |
singlestoredb/tests/test_function_url.py |
Tests URL parsing and ownership classification. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 18a98b1. Configure here.
kesmit13
left a comment
There was a problem hiding this comment.
I don't see anything obviously incorrect. Just make sure to address the AI reviews.


Summary
Interactive
run_udf_app()usedCREATE OR REPLACEby name, so a notebook session could steal a published Python UDF SQL function onto/pythonudfs/<session>/interactive/. After the session died the function failed.Interactive registration now reads
SHOW CREATE, then only creates a missing name or replaces a function that already points at this session URL. Published and other-session functions are left alone. The_testsuffix is unchanged. CLI / mmap still useregister_functions(replace=True).Pairs with Helios #28074 (Portal republish / idle-wake repair).
Test Plan
run_udf_app()on the same names, confirm published SQL is unchanged, then republish and confirm the published URL is restoredNote
Medium Risk
Changes MCDB SQL registration behavior for interactive notebooks (data-plane metadata); mistakes could leave wrong URLs or block legitimate re-registration, but published UDFs are explicitly protected and non-interactive publish paths are unchanged.
Overview
Fixes interactive notebook registration so it no longer overwrites published or other-session Python UDF SQL definitions that used blind
CREATE OR REPLACEviaregister_functions(replace=True).Interactive flows now
SHOW CREATEeach target name, parse the MANAGED/SERVICE URL (function_url.py), and only create missing names or replace functions already bound to this session’s/interactive/URL.preflight_interactive_functions()runs that check before shutting down the prior uvicorn server or killing the port, so a name conflict fails without tearing down a working server.register_interactive_functions()drops stale functions owned by this URL only, re-checks ownership before each write, and logs registered SQL names after startup._locate_app_functionsuses the same URL helpers for matching. CLI / mmap publish paths still useregister_functions(replace=True). Unit tests cover URL parsing, refusal cases, stale drops, and startup ordering.Reviewed by Cursor Bugbot for commit 0288dd7. Bugbot is set up for automated code reviews on this repo. Configure here.