Skip to content

Fix duplicate Studio asset URI scheme#160

Merged
jackTabsCode merged 2 commits into
jackTabsCode:mainfrom
revvy02:fix-studio-double-prefix
May 6, 2026
Merged

Fix duplicate Studio asset URI scheme#160
jackTabsCode merged 2 commits into
jackTabsCode:mainfrom
revvy02:fix-studio-double-prefix

Conversation

@revvy02
Copy link
Copy Markdown
Contributor

@revvy02 revvy02 commented Apr 27, 2026

Summary

The Display impl for AssetRef already prepends rbxasset:// for Studio variants and rbxassetid:// for Cloud variants:

impl fmt::Display for AssetRef {
    AssetRef::Cloud(id)    => write!(f, "rbxassetid://{id}"),
    AssetRef::Studio(name) => write!(f, "rbxasset://{name}"),
}

The studio backend was packing those prefixes inside the inner string as well, so codegen ended up emitting doubled URLs:

-- output/assets.luau on `asphalt sync studio` against current main:
local assets = {
    ["test1.png"] = "rbxasset://rbxasset://.asphalt-myproject/<hash>.png",
}

For models/animations with a lockfile entry (i.e. already cloud-uploaded), the result was even more confused:

["my_model.rbxm"] = "rbxasset://rbxassetid://12345"

Fix

  • For locally synced files, drop the rbxasset:// prefix from the inner string of AssetRef::Studio(...) so Display adds it once.
  • For cloud-uploaded models/animations, return AssetRef::Cloud(entry.asset_id) so the correct rbxassetid://{id} is produced via Display.

Test infrastructure

This PR also adds an ASPHALT_TEST env var that routes the studio sync folder to params.project_dir instead of the Roblox Studio content path. This is test-only plumbing — the existing common test harness (tests/common/mod.rs) already sets ASPHALT_TEST=true in Project::run(), but the studio backend ignored it. With the env var honored, integration tests for sync studio no longer require a Roblox Studio install.

Regression test

Added studio_sync_emits_single_rbxasset_prefix in tests/sync.rs. It runs asphalt sync studio and asserts that the generated output/assets.luau:

  • Contains rbxasset://.asphalt-test/ (single prefix, correct format)
  • Does NOT contain rbxasset://rbxasset://
  • Does NOT contain rbxasset://rbxassetid://

I verified the test fails on current main (captured output: ["test1.png"] = "rbxasset://rbxasset://.asphalt-...") and passes with the fix.

Test plan

  • cargo build clean on rc.5
  • cargo test — 6/6 unit + 11/11 integration pass
  • New regression test fails on main without the fix

The Display impl for AssetRef already prepends "rbxasset://" for Studio
and "rbxassetid://" for Cloud variants. The studio backend was packing
those prefixes inside the inner string, causing codegen to emit doubled
URLs like:

  ["test1.png"] = "rbxasset://rbxasset://.asphalt-name/<hash>.png"

For cloud-uploaded models/animations, return AssetRef::Cloud(id) so the
correct "rbxassetid://{id}" is produced. For locally synced files, drop
the "rbxasset://" prefix from the inner string so Display adds it once.

Also adds an ASPHALT_TEST env var that routes the sync folder to the
project directory instead of the Roblox Studio content path. This is
test-only plumbing that lets the integration test exercise sync studio
without requiring a Roblox Studio install. The common test harness
already sets this env var in Project::run().

Includes a regression test (studio_sync_emits_single_rbxasset_prefix)
that fails on the previous behavior.
@revvy02 revvy02 force-pushed the fix-studio-double-prefix branch from 5102258 to 3176b0a Compare April 27, 2026 07:17
@jackTabsCode
Copy link
Copy Markdown
Owner

Hey. Thanks for the fix, but I don't think we need these tests. Do you mind reducing your PR to the few lines of code necessary to fix us adding that prefix?

Reduces PR jackTabsCode#160 to just the prefix fix in studio.rs as requested.
@revvy02
Copy link
Copy Markdown
Contributor Author

revvy02 commented May 5, 2026

removed tests, just the minimal fix now

@jackTabsCode jackTabsCode changed the title fix(studio): drop double rbxasset:// / rbxassetid:// prefix in AssetRef Fix duplicate Studio asset URI scheme May 6, 2026
@jackTabsCode jackTabsCode merged commit 0fa50ad into jackTabsCode:main May 6, 2026
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