Skip to content

fix(exec): run on an unpublished app through its preview URL - #693

Open
davidsu wants to merge 1 commit into
mainfrom
fix/exec-unpublished-app
Open

davidsu wants to merge 1 commit into
mainfrom
fix/exec-unpublished-app

Conversation

@davidsu

@davidsu davidsu commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Note

Description

base44 exec failed on an app that was never published, because it always resolved the target host via the published-URL lookup, which only answers for live apps and returns 404 App not found otherwise. This PR falls back to the app's preview URL (https://preview--<appId>.base44.app) when that lookup 404s, so scripts can run against an unpublished app's data and backend functions — which already serve its editors there. Any other failure from the lookup still propagates unchanged.

Related Issue

None

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Other (please describe):

Changes Made

  • core/exec/run-script.ts: added resolveAppBaseUrl(), which wraps getSiteUrl() and returns appPreviewUrl(appId) on an ApiError with status 404; all other errors are rethrown.
  • Remote mode now resolves BASE44_APP_BASE_URL through resolveAppBaseUrl(appId) instead of calling getSiteUrl() directly. Local mode is untouched.
  • backend-runtime/exec.ts: updated the BASE44_APP_BASE_URL doc comment to mention the preview-URL fallback.
  • CHANGELOG.md: new entry under Fixed.
  • Tests: two new cases in tests/core/exec-run-script.spec.ts — a 404 lookup runs the script against the preview URL, and a 401 lookup rejects with the original error without spawning the runtime.

Testing

  • I have tested these changes locally
  • I have added/updated tests as needed
  • All tests pass (`npm test`)

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (if applicable)
  • My changes generate no new warnings
  • I have updated `docs/` (AGENTS.md) if I made architectural changes

Additional Notes

The preview host is built from a hardcoded `https://preview--.base44.app` template rather than being returned by the API, so it is tied to the current preview-domain scheme; it is the only occurrence of that pattern in `src/`. The narrow 404-only condition keeps genuine auth/permission failures (e.g. a workspace API key being refused) surfacing as errors instead of silently redirecting the script at a preview host.


🤖 Generated by Claude | 2026-11-04 17:57 UTC | 36e994c

`exec` points the SDK at the URL from `published-url`, which answers
only for live apps since base44-dev/apper#20913, so every unpublished
app failed with "Error fetching site URL: App not found" before the
script ran. On that 404, `exec` now targets the app's static preview
host, `https://preview--{appId}.base44.app`, where the app's data and
backend functions already serve its editors. The platform host
`app.base44.com` is not an option: backend functions refuse it.

BUG-893: https://issue-tracker.base44.app/issue/BUG-893
Task: https://b44sync.base44.app/rd-hub/tasks/BASE-50245
https://github.com/base44-dev/suss-tasks/blob/fd07b57e2a0f1560d5dec5a4a47d6a7af7b40609/cli/exec_unpublished_app_not_found%F0%9F%9A%AA/respond_support_help.md
gate: tests/core/exec-run-script.spec.ts

agent: bug893.owner
@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

🚀 Package Preview Available!


Install this PR's preview build with npm:

npm i @base44-preview/cli@0.3.1-pr.693.36e994c

Prefer not to change any import paths? Install using npm alias so your code still imports base44:

npm i "base44@npm:@base44-preview/cli@0.3.1-pr.693.36e994c"

Or add it to your package.json dependencies:

{
  "dependencies": {
    "base44": "npm:@base44-preview/cli@0.3.1-pr.693.36e994c"
  }
}

Preview published to npm registry — try new features instantly!

@davidsu

davidsu commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

Verified end to end on a never-published staff test app (6a1c0f0b9e32b83c0b6b41e7, no functions on it before). Deployed one trivial function with base44 functions deploy hello, then ran this branch's build (0b596cf) from a project linked to the app:

$ base44 exec < script.ts     # script: auth.me(), then functions.invoke("hello", { from: "exec on branch 0b596cf" })
auth.me role: admin
functions.invoke(hello) status: 200
functions.invoke(hello) data: {"hello":"from unpublished app","echo":{"from":"exec on branch 0b596cf"}}

The released CLI on the same app and script still fails before Deno starts:

Error: Error fetching site URL: App not found
  Hint: The requested resource was not found

agent: exec.unpublished

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