Skip to content

Fix file permissions for uploaded assets to prevent 403 errors#33

Open
Copilot wants to merge 3 commits into
mainfrom
copilot/fix-image-file-permissions
Open

Fix file permissions for uploaded assets to prevent 403 errors#33
Copilot wants to merge 3 commits into
mainfrom
copilot/fix-image-file-permissions

Conversation

Copilot AI commented Oct 7, 2025

Copy link
Copy Markdown
Contributor

Problem

When uploading assets via the lameco:upload_assets task, files could retain their local permissions (e.g., 600), which causes 403 Permission Denied errors when the web server tries to serve them. Since file permissions are not tracked in Git, this is a local environment issue that needs to be handled during deployment.

Solution

This PR ensures all uploaded asset files have at least 644 permissions (read/write for owner, read for group and others) by automatically setting permissions on the server side after upload.

Changes Made

For asset directories:
After uploading each directory, the task now runs:

find {{release_path}}/<dir> -type f -exec chmod 644 {} +

This recursively sets 644 permissions on all files within the uploaded directory.

For individual asset files:
After uploading each file, the task now runs:

chmod 644 {{release_path}}/<file>

This ensures the individual file has the correct permissions.

Example Output

When running the task, you'll now see:

Uploading assets directory: public/dist...
Setting permissions to at least 644 for files in: public/dist...

This provides visibility into the permission-setting process and confirms the operation completed successfully.

Benefits

  • ✅ Prevents 403 Permission Denied errors for web-accessible assets
  • ✅ Works consistently regardless of local file permissions
  • ✅ Handles both bulk directory uploads and individual file uploads
  • ✅ Server-side solution ensures permissions are always correct in production
  • ✅ Minimal code changes with clear, informative logging

Fixes #32

Original prompt

This section details on the original issue you should resolve

<issue_title>In the lameco:upload_assets task make sure the permissions of all files are at least 644</issue_title>
<issue_description>For some reason I had a image with 600 permissions which returns a 403 Permissions denied when trying to visit or load the image.
Since this is a local permissions issue and not stored in Git it would be nice to always update the permissions either on the client or server side when building/uploading the assets.</issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes #32

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@sander-lameco sander-lameco marked this pull request as ready for review October 7, 2025 06:54
Copilot AI and others added 2 commits October 7, 2025 06:54
Co-authored-by: sander-lameco <25500086+sander-lameco@users.noreply.github.com>
Co-authored-by: sander-lameco <25500086+sander-lameco@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix image file permissions to ensure accessibility Fix file permissions for uploaded assets to prevent 403 errors Oct 7, 2025
Copilot AI requested a review from sander-lameco October 7, 2025 06:56
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.

In the lameco:upload_assets task make sure the permissions of all files are at least 644

2 participants