Skip to content

[python] Always pass in wsgi/asgi app variable name to python runtime - #15635

Merged
msullivan merged 18 commits into
mainfrom
python-app-detect
Mar 24, 2026
Merged

msullivan merged 18 commits into
mainfrom
python-app-detect

Conversation

@msullivan

@msullivan msullivan commented Mar 19, 2026 •

Copy link
Copy Markdown
Contributor

Currently we do detection both in the python builder and in the runtime. Adjust that so that we always actually extract the wsgi/asgi entry point name in the builder and pass it to the runtime.

(We still do some runtime detection for workers/crons, though, and may want to revisit that later)

@changeset-bot

changeset-bot Bot commented Mar 19, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: ba1dd27

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 19 packages
Name Type
@vercel/python-analysis Minor
@vercel/python-runtime Minor
@vercel/build-utils Minor
@vercel/python Minor
@vercel/backends Patch
vercel Patch
@vercel/client Patch
@vercel/elysia Patch
@vercel/express Patch
@vercel/fastify Patch
@vercel/fs-detectors Patch
@vercel/gatsby-plugin-vercel-builder Patch
@vercel/h3 Patch
@vercel/hono Patch
@vercel/koa Patch
@vercel/nestjs Patch
@vercel/node Patch
@vercel/static-build Patch
@vercel/cervel Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel

vercel Bot commented Mar 19, 2026 •

Copy link
Copy Markdown
Contributor

Low Risk — Refactor of Python entrypoint detection to always pass variable name — internal build tooling change.

  • entrypoint.rs: find_app_or_handler_impl now returns Option<String> instead of bool
  • vc_init.py: __VC_HANDLER_VARIABLE_NAME changed from optional to required env var
  • entrypoint.ts: detection functions now return PythonEntrypoint struct with both path and variable name

Assessed at ba1dd27.

@github-actions

github-actions Bot commented Mar 20, 2026 •

Copy link
Copy Markdown
Contributor

📦 CLI Tarball Ready

The Vercel CLI tarball for this PR is now available!

Quick Test

You can test this PR's CLI directly by running:

npx https://vercel-fmazw00f6.vercel.sh/tarballs/vercel.tgz --help

Use in vercel.json

To use this CLI version in your project builds, add to your vercel.json:

{
  "build": {
    "env": {
      "VERCEL_CLI_VERSION": "vercel@https://vercel-fmazw00f6.vercel.sh/tarballs/vercel.tgz"
    }
  }
}

Python Runtime Wheel

A vercel-runtime wheel was also built for this PR.
To use in your Python project builds, also set this environment variable:

VERCEL_RUNTIME_PYTHON="vercel-runtime @ https://vercel-fmazw00f6.vercel.sh/tarballs/vercel_runtime-0.11.0.dev1774045648+4349436-py3-none-any.whl"

Python Workers Wheel

A vercel-workers wheel was also built for this PR.
To use in your Python project builds, also set this environment variable:

VERCEL_WORKERS_PYTHON="vercel-workers @ https://vercel-fmazw00f6.vercel.sh/tarballs/vercel_workers-0.1.0.dev1774045648+4349436-py3-none-any.whl"

@github-actions

github-actions Bot commented Mar 20, 2026 •

Copy link
Copy Markdown
Contributor

🧪 Unit Test Strategy

Comparing: 4839214 → ba1dd27 (view diff)

Strategy: Code changed outside of a package - running all unit tests

⚠️ All unit tests will run because global code changes could impact all packages.

Affected packages - 40 (100%)
  1. @vercel-internals/get-package-json
  2. @vercel/backends
  3. @vercel/build-utils
  4. @vercel/cervel
  5. @vercel/cli-auth
  6. @vercel/client
  7. @vercel/config
  8. @vercel/detect-agent
  9. @vercel/edge
  10. @vercel/elysia
  11. @vercel/error-utils
  12. @vercel/express
  13. @vercel/fastify
  14. @vercel/firewall
  15. @vercel/frameworks
  16. @vercel/fs-detectors
  17. @vercel/functions
  18. @vercel/gatsby-plugin-vercel-builder
  19. @vercel/go
  20. @vercel/h3
  21. @vercel/hono
  22. @vercel/hydrogen
  23. @vercel/koa
  24. @vercel/nestjs
  25. @vercel/next
  26. @vercel/node
  27. @vercel/oidc
  28. @vercel/oidc-aws-credentials-provider
  29. @vercel/python
  30. @vercel/python-analysis
  31. @vercel/redwood
  32. @vercel/related-projects
  33. @vercel/remix-builder
  34. @vercel/routing-utils
  35. @vercel/ruby
  36. @vercel/rust
  37. @vercel/static-build
  38. @vercel/static-config
  39. examples
  40. vercel

Results

  • Unit tests: All affected packages will run unit tests
  • E2E tests: Running in parallel via E2E Tests workflow
  • Type checks: All affected packages will run type checks

This comment is automatically generated based on the affected testing strategy

@msullivan msullivan changed the title [WIP] test python app detection changes [python] Always pass in wsgi/asgi app variable name to python runtime Mar 23, 2026
@msullivan
msullivan marked this pull request as ready for review March 23, 2026 18:16
@msullivan
msullivan requested review from a team as code owners March 23, 2026 18:16
@msullivan
msullivan requested a review from agadzik as a code owner March 23, 2026 18:16
Comment thread packages/fs-detectors/src/index.ts Resolved
`contains_app_or_handler` now returns the matched variable name
(e.g. "app", "application", "handler") instead of a boolean, threaded
through the full stack: Rust WASM, WIT, TS wrappers, and builder
entrypoint detection.
Call `resolve_app` unconditionally instead of checking `__vc_variables`
for "handler"/"app"/"application" first. If the resolved object is a
`BaseHTTPRequestHandler` subclass named "handler", use the HTTP handler
path; otherwise fall into WSGI/ASGI detection.

Also make `resolve_app` take a required `str` (no longer `str | None`)
and route its error through `_fatal` for a user-friendly message with
docs link.
…_type`

Instead of fataling with a specific error when a `handler` class
does not inherit from `BaseHTTPRequestHandler`, let it fall through
to `detect_app_type` which will report the generic "could not
determine the application interface" error. This makes both the
IPC and legacy Lambda paths consistent.

Also wrap `detect_app_type` calls in try/except so the error goes
through `_fatal` (and thus IPC) instead of crashing the process.
Add `type` to `BuildOptions.service` so builders can detect whether
they are building a cron, worker, or web service. Use this in the
Python builder to default `variableName` to "app" for cron/worker
services whose entrypoints lack a detectable top-level callable
(these services dynamically create an `app` at runtime).

For normal functions, error when no callable is found in the
entrypoint file.
@msullivan
msullivan merged commit 25a6a2d into main Mar 24, 2026
212 of 216 checks passed
@msullivan
msullivan deleted the python-app-detect branch March 24, 2026 02:28
ijjk added a commit that referenced this pull request Mar 24, 2026
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## @vercel/[email protected]

### Minor Changes

- [services] support multiple topics for a single worker service
([#15615](#15615))

- [services] support for specifying an env prefix for each service
([#15641](#15641))

- Simplify python runtime by always passing in app variable
([#15635](#15635))

### Patch Changes

- Namespace diagnostics keys by builder and service workspace, and
aggregate per-builder `package-manifest.json` files into a single
`project-manifest.json`
([#15399](#15399))

- Updated dependencies
\[[`ac87d5a5ef5d79b55765e094efc957de987d7ac4`](ac87d5a),
[`25a6a2daa46baba6e8d7dec90eb49213b8150b8c`](25a6a2d)]:
    -   @vercel/[email protected]

## [email protected]

### Minor Changes

- [services] support multiple topics for a single worker service
([#15615](#15615))

- [services] support for specifying an env prefix for each service
([#15641](#15641))

### Patch Changes

- fix(cli): support installation-level metadata for `integration add`
([#15444](#15444))

Integrations like Sentry have both product-level metadata (e.g.
`platform`) and installation-level metadata (e.g. `name`, `region`). The
CLI now:

    -   Shows installation-level metadata fields in `--help` output
    -   Accepts installation-level metadata keys via `-m` flags
- Splits metadata into product and installation buckets, sending
`installationMetadata` as a separate API field
- Shows actionable hint when required metadata is missing on browser
fallback (lists missing fields with example `-m` flags)
- Forwards `installationMetadata` to browser fallback URL so
installation config isn't lost on redirect
- Logs debug warning when product and installation schemas have
overlapping key names

- Redirect sources now support domains
([#15670](#15670))

- Improve buy command error handling: handle new API error codes
(invalid_plan, already_on_plan, invalid_status, forbidden,
purchase_create_hosted_failed), distinguish 402 payment failures from
server errors, and auto-open billing page in TTY mode for
payment-related errors.
([#15699](#15699))

- Namespace diagnostics keys by builder and service workspace, and
aggregate per-builder `package-manifest.json` files into a single
`project-manifest.json`
([#15399](#15399))

- Updated dependencies
\[[`69cd8ea307f507037fe735d7ba09c58fb4193e13`](69cd8ea),
[`e921c3f3f42cd436525c05627109115bcffc9f4c`](e921c3f),
[`bb98cc3b9a303b9e598c14feca5c0f36128bcf7f`](bb98cc3),
[`4839214ae9cbcc95d448429bf93133e58284e03f`](4839214),
[`ac87d5a5ef5d79b55765e094efc957de987d7ac4`](ac87d5a),
[`ece813e0a9a75e3ad262817f00050c62f5ad67eb`](ece813e),
[`d7107d025500d6be305895dfd5cd89d87e6eb9f0`](d7107d0),
[`25a6a2daa46baba6e8d7dec90eb49213b8150b8c`](25a6a2d),
[`f02b9da61d1acac5b426d8757e9bfb4ba4ffedd8`](f02b9da)]:
    -   @vercel/[email protected]
    -   @vercel/[email protected]
    -   @vercel/[email protected]
    -   @vercel/[email protected]
    -   @vercel/[email protected]
    -   @vercel/[email protected]
    -   @vercel/[email protected]
    -   @vercel/[email protected]
    -   @vercel/[email protected]
    -   @vercel/[email protected]
    -   @vercel/[email protected]
    -   @vercel/[email protected]
    -   @vercel/[email protected]
    -   @vercel/[email protected]
    -   @vercel/[email protected]
    -   @vercel/[email protected]
    -   @vercel/[email protected]
    -   @vercel/[email protected]
    -   @vercel/[email protected]

## @vercel/[email protected]

### Minor Changes

- [services] support multiple topics for a single worker service
([#15615](#15615))

- [services] support for specifying an env prefix for each service
([#15641](#15641))

### Patch Changes

- Updated dependencies
\[[`13f719da050ba4b73b95b51e8edf7141c967b9a2`](13f719d)]:
    -   @vercel/[email protected]

## @vercel/[email protected]

### Minor Changes

- [services] support multiple topics for a single worker service
([#15615](#15615))

- [services] support for specifying an env prefix for each service
([#15641](#15641))

### Patch Changes

- Updated dependencies
\[[`4839214ae9cbcc95d448429bf93133e58284e03f`](4839214),
[`13f719da050ba4b73b95b51e8edf7141c967b9a2`](13f719d),
[`ece813e0a9a75e3ad262817f00050c62f5ad67eb`](ece813e),
[`d7107d025500d6be305895dfd5cd89d87e6eb9f0`](d7107d0),
[`25a6a2daa46baba6e8d7dec90eb49213b8150b8c`](25a6a2d)]:
    -   @vercel/[email protected]
    -   @vercel/[email protected]
    -   @vercel/[email protected]

## @vercel/[email protected]

### Minor Changes

- Update uv to v0.10.11
([#15623](#15623))

- Simplify python runtime by always passing in app variable
([#15635](#15635))

### Patch Changes

- Fix env marker-excluded deps erroneously flagged as lacking wheels
([#15668](#15668))

- Updated dependencies
\[[`ac87d5a5ef5d79b55765e094efc957de987d7ac4`](ac87d5a),
[`25a6a2daa46baba6e8d7dec90eb49213b8150b8c`](25a6a2d)]:
    -   @vercel/[email protected]

## @vercel/[email protected]

### Minor Changes

- Simplify python runtime by always passing in app variable
([#15635](#15635))

### Patch Changes

- Fix env marker-excluded deps erroneously flagged as lacking wheels
([#15668](#15668))

## @vercel/[email protected]

### Patch Changes

- Bump @vercel/nft to 1.5.0
([#15683](#15683))

- Updated dependencies
\[[`4839214ae9cbcc95d448429bf93133e58284e03f`](4839214),
[`ece813e0a9a75e3ad262817f00050c62f5ad67eb`](ece813e),
[`d7107d025500d6be305895dfd5cd89d87e6eb9f0`](d7107d0),
[`25a6a2daa46baba6e8d7dec90eb49213b8150b8c`](25a6a2d)]:
    -   @vercel/[email protected]

## @vercel/[email protected]

### Patch Changes

- Updated dependencies
\[[`69cd8ea307f507037fe735d7ba09c58fb4193e13`](69cd8ea)]:
    -   @vercel/[email protected]

## @vercel/[email protected]

### Patch Changes

- Updated dependencies
\[[`4839214ae9cbcc95d448429bf93133e58284e03f`](4839214),
[`13f719da050ba4b73b95b51e8edf7141c967b9a2`](13f719d),
[`ece813e0a9a75e3ad262817f00050c62f5ad67eb`](ece813e),
[`d7107d025500d6be305895dfd5cd89d87e6eb9f0`](d7107d0),
[`25a6a2daa46baba6e8d7dec90eb49213b8150b8c`](25a6a2d)]:
    -   @vercel/[email protected]
    -   @vercel/[email protected]

## @vercel/[email protected]

### Patch Changes

- Updated dependencies
\[[`69cd8ea307f507037fe735d7ba09c58fb4193e13`](69cd8ea)]:
    -   @vercel/[email protected]

## @vercel/[email protected]

### Patch Changes

- Bump @vercel/nft to 1.5.0
([#15683](#15683))

- Updated dependencies
\[[`69cd8ea307f507037fe735d7ba09c58fb4193e13`](69cd8ea)]:
    -   @vercel/[email protected]
    -   @vercel/[email protected]

## @vercel/[email protected]

### Patch Changes

- Updated dependencies
\[[`69cd8ea307f507037fe735d7ba09c58fb4193e13`](69cd8ea)]:
    -   @vercel/[email protected]

## @vercel/[email protected]

### Patch Changes

- Updated dependencies
\[[`4839214ae9cbcc95d448429bf93133e58284e03f`](4839214),
[`ece813e0a9a75e3ad262817f00050c62f5ad67eb`](ece813e),
[`d7107d025500d6be305895dfd5cd89d87e6eb9f0`](d7107d0),
[`25a6a2daa46baba6e8d7dec90eb49213b8150b8c`](25a6a2d)]:
    -   @vercel/[email protected]

## @vercel/[email protected]

### Patch Changes

- Updated dependencies
\[[`69cd8ea307f507037fe735d7ba09c58fb4193e13`](69cd8ea)]:
    -   @vercel/[email protected]

## @vercel/[email protected]

### Patch Changes

- Bump @vercel/nft to 1.5.0
([#15683](#15683))

- Updated dependencies
\[[`69cd8ea307f507037fe735d7ba09c58fb4193e13`](69cd8ea)]:
    -   @vercel/[email protected]

## @vercel/[email protected]

### Patch Changes

- Updated dependencies
\[[`69cd8ea307f507037fe735d7ba09c58fb4193e13`](69cd8ea)]:
    -   @vercel/[email protected]

## @vercel/[email protected]

### Patch Changes

- Updated dependencies
\[[`69cd8ea307f507037fe735d7ba09c58fb4193e13`](69cd8ea)]:
    -   @vercel/[email protected]

## @vercel/[email protected]

### Patch Changes

- Bump @vercel/nft to 1.5.0
([#15683](#15683))

- fix(next): merge next-minimal-server.js.nft.json into server trace for
prebuilt deployments
([#15688](#15688))

- Update to latest Next.js adapter
([#15695](#15695))

## @vercel/[email protected]

### Patch Changes

- Bump @vercel/nft to 1.5.0
([#15683](#15683))

- Updated dependencies
\[[`4839214ae9cbcc95d448429bf93133e58284e03f`](4839214),
[`ece813e0a9a75e3ad262817f00050c62f5ad67eb`](ece813e),
[`d7107d025500d6be305895dfd5cd89d87e6eb9f0`](d7107d0),
[`25a6a2daa46baba6e8d7dec90eb49213b8150b8c`](25a6a2d)]:
    -   @vercel/[email protected]

## @vercel/[email protected]

### Patch Changes

- Bump @vercel/nft to 1.5.0
([#15683](#15683))

## @vercel/[email protected]

### Patch Changes

- Bump @vercel/nft to 1.5.0
([#15683](#15683))

## @vercel/[email protected]

### Patch Changes

- Redirect sources now support domains
([#15670](#15670))

## @vercel/[email protected]

### Patch Changes

-   Updated dependencies \[]:
    -   @vercel/[email protected]

## @vercel/[email protected]

### Minor Changes

- Update uv to v0.10.11
([#15623](#15623))

- Simplify python runtime by always passing in app variable
([#15635](#15635))

### Patch Changes

- Fix a flakey unit test
([#15647](#15647))

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: JJ Kasper <[email protected]>

This branch was successfully deployed

1 active deployment
Preview — ba1dd279 Deployed Mar 24, 2026 by vercel[bot]
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