Skip to content

Issues/1263 scope assets to project in scratch#783

Draft
abcampo-iry wants to merge 5 commits intomainfrom
issues/1263-scope-assets-to-project-in-scratch
Draft

Issues/1263 scope assets to project in scratch#783
abcampo-iry wants to merge 5 commits intomainfrom
issues/1263-scope-assets-to-project-in-scratch

Conversation

@abcampo-iry
Copy link
Copy Markdown
Contributor

Status

  • Closes partially 1256

What's changed?

Scratch assets are no longer treated as shared by everyone.
Uploaded assets are now linked to a Scratch project using project_id. This means:

  • a project can only load its own assets
  • remixes can still load assets from ancestor projects
  • Scratch library assets still work as global assets
  • two different projects can upload the same asset filename

The Scratch asset endpoints are now stricter:

  • X-Project-ID is required
  • asset reads and uploads are checked against that project
  • project SVG assets are no longer served as trusted image/svg+xml
  • only global library SVG assets use image/svg+xml

Scratch project access is also stricter:

  • only allowed users can open or update a Scratch project
  • remix creation reuses an existing remix instead of creating duplicates

There is also a fix for students remixing teacher projects:

  • if a student uploads a new Scratch asset before doing the first explicit remix save
  • the API now creates or reuses the student’s remix automatically for that asset
  • later saves continue using that same remix

The migration adds project_id to scratch_assets and backfills old assets onto the projects that reference them.
If the same old asset is used by multiple projects, the migration creates one asset row per project but reuses the same stored blob, so files are not copied.
Global assets are represented by project_id = nil.

This makes Scratch assets private to the right project instead of globally readable, while still keeping:

  • remixes working
  • Scratch library assets working
  • duplicate uploads across projects working

@cla-bot cla-bot bot added the cla-signed label Apr 14, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 14, 2026

Test coverage

89.6% line coverage reported by SimpleCov.
Run: https://github.com/RaspberryPiFoundation/editor-api/actions/runs/24410129041

@abcampo-iry abcampo-iry force-pushed the issues/1263-scope-assets-to-project-in-scratch branch from ef4870e to ddfaa05 Compare April 14, 2026 16:15
@raspberrypiherokubot raspberrypiherokubot temporarily deployed to editor-api-p-issues-126-edxmgm April 14, 2026 16:15 Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants