Skip to content

[backend:fix] fix interactive and portal publish PythonUDF MCDB-100138 #closes - #138

Merged
kesmit13 merged 5 commits into
mainfrom
MCDB-100138/karish-chaudhary/udf-publish-fixes
Oct 1, 2026
Merged

kesmit13 merged 5 commits into
mainfrom
MCDB-100138/karish-chaudhary/udf-publish-fixes

Conversation

@KarishS2

@KarishS2 KarishS2 commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Interactive run_udf_app() used CREATE OR REPLACE by 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 _test suffix is unchanged. CLI / mmap still use register_functions(replace=True).

Pairs with Helios #28074 (Portal republish / idle-wake repair).

Test Plan

  • Added unit tests for SHOW CREATE URL parse and interactive create / replace / refuse
  • Staging test with Helios #28074: publish a UDF, run run_udf_app() on the same names, confirm published SQL is unchanged, then republish and confirm the published URL is restored

Note

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 REPLACE via register_functions(replace=True).

Interactive flows now SHOW CREATE each 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_functions uses the same URL helpers for matching. CLI / mmap publish paths still use register_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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Registration can leave partial or stale SQL definitions pointing to an unavailable endpoint.

Review effort: Balanced
Findings: 2 Medium severity

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.

Comment thread singlestoredb/functions/ext/asgi.py
Comment thread singlestoredb/functions/ext/asgi.py Outdated

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ 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.

Comment thread singlestoredb/functions/ext/function_url.py

@kesmit13 kesmit13 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I don't see anything obviously incorrect. Just make sure to address the AI reviews.

@KarishS2 KarishS2 changed the title [backend:fix] fix interactive and portal publish PythonUDF MCDB-100138 [backend:fix] fix interactive and portal publish PythonUDF MCDB-100138 #closes Oct 1, 2026
@kesmit13
kesmit13 merged commit ec47daa into main Oct 1, 2026
14 checks passed
@kesmit13
kesmit13 deleted the MCDB-100138/karish-chaudhary/udf-publish-fixes branch October 1, 2026 12:45

This branch was successfully deployed

1 active deployment
Base — 0288dd7d Deployed Oct 1, 2026 by KarishS2 via test-coverage #536
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.

4 participants