Skip to content

Modern Docker Management, Designed for Everyone

fix: discover and diagnose projects with an unreadable .env (#3909)

Kyle Mendelle8c92c5e6bae
diff --git a/backend/internal/common/errors.go b/backend/internal/common/errors.go
index f41719d1d..864037287 100644
--- a/backend/internal/common/errors.go
+++ b/backend/internal/common/errors.go
@@ -18,6 +18,10 @@ const (
ErrUnavailable = errors.Sentinel("kind: service unavailable")
)
+// ConfigurationErrorCodeEnvFileUnreadable is the ConfigurationError code reported
+// alongside ErrProjectEnvUnreadable.
+const ConfigurationErrorCodeEnvFileUnreadable = "env_file_unreadable"
+
type classified struct {
kind error
err error
@@ -114,6 +118,7 @@ var (
ErrProjectComposeFileNotFound = Classify(ErrNotFound, errors.Sentinel("Project compose file not found"))
ErrComposeFileNotFound = Classify(ErrNotFound, errors.Sentinel("no compose file found"))
ErrComposeFileEnvInvalid = Classify(ErrValidation, errors.Sentinel("invalid COMPOSE_FILE selection"))
+ ErrProjectEnvUnreadable = Classify(ErrValidation, errors.Sentinel("project env file is not readable"))
ErrEnvironmentInvalidProxyTarget = Classify(ErrBadRequest, errors.Sentinel("Invalid proxy target URL"))
ErrEnvironmentConnectionTestFailed = Classify(ErrBadRequest, errors.Sentinel("Environment connection test failed"))
ErrUnsafeRemoteURL = Classify(ErrBadRequest, errors.Sentinel("Remote URL is not allowed"))
diff --git a/backend/internal/project/handler.go b/backend/internal/project/handler.go
index 2c9307448..a6592546e 100644
--- a/backend/internal/project/handler.go
+++ b/backend/internal/project/handler.go
@@ -606,7 +606,7 @@ func (h *ProjectHandler) DownProject(ctx context.Context, input *DownProjectInpu
if err := h.projectService.DownProject(downCtx, input.ProjectID, *user); err != nil {
activitylib.FlushWriter(activityWriter)
activitylib.CompleteHandlerActivity(runtimeCtx, h.activityService, activityID, "Project stopped", err)
- if errors.Is(err, common.ErrProjectArchived) {
+ if errors.Is(err, common.ErrProjectArchived) || errors.Is(err, common.ErrProjectEnvUnreadable) {
return nil, huma.Error400BadRequest(err.Error())
}
return nil, huma.Error500InternalServerError(errors.WithMessage(err, "Failed to bring down project").Error())
@@ -1198,7 +1198,7 @@ func projectWorkspaceHTTPErrorInternal(err error) error {
return huma.Error403Forbidden(err.Error())
case errors.Is(err, common.ErrProjectWorkspaceNotFound), errors.Is(err, common.ErrProjectNotFound):
return huma.Error404NotFound(err.Error())
- case errors.Is(err, common.ErrProjectWorkspaceBadRequest):
+ case errors.Is(err, common.ErrProjectWorkspaceBadRequest), errors.Is(err, common.ErrProjectEnvUnreadable):
return huma.Error400BadRequest(err.Error())
default:
return huma.Error500InternalServerError("internal error")
diff --git a/backend/internal/project/project.go b/backend/internal/project/project.go
index afdaec7fb..2cc0c0dd2 100644
--- a/backend/internal/project/project.go
+++ b/backend/internal/project/project.go
@@ -584,6 +584,9 @@ func (s *ProjectService) ResolveProjectComposeFile(ctx context.Context, proj *Pr
composeFile, err := projects.DetectComposeFile(ctx, projectsDirectory, proj.Path)
if err != nil {
+ if errors.Is(err, common.ErrProjectEnvUnreadable) {
+ return "", err
+ }
return "", common.Classify(common.ErrProjectComposeFileNotFound, errors.WrapIf(err, "Project compose file not found"))
}
@@ -635,6 +638,10 @@ func (s *ProjectService) refreshComposeProjectNameInternal(ctx context.Context,
meta, err := s.loadComposeMetadataForSyncInternal(ctx, proj.Path, dirName)
if err != nil {
+ if errors.Is(err, common.ErrProjectEnvUnreadable) {
+ slog.DebugContext(ctx, "skipped compose project name refresh; project env is unreadable", "projectID", proj.ID, "path", proj.Path, "error", err)
+ return
+ }
slog.WarnContext(ctx, "failed to refresh compose project name", "projectID", proj.ID, "path", proj.Path, "error", err)
return
}
diff --git a/backend/internal/project/project_details.go b/backend/internal/project/project_details.go
index 0c87dc64d..ebf022322 100644
--- a/backend/internal/project/project_details.go
+++ b/backend/internal/project/project_details.go
@@ -105,6 +105,9 @@ func (s *ProjectService) GetProjectServices(ctx context.Context, projectID strin
}
composeProject, composeFileFullPath, derr := s.loadComposeProjectForProjectInternal(ctx, projectFromDb)
+ if errors.Is(derr, common.ErrProjectEnvUnreadable) {
+ return s.projectServicesFromContainersInternal(ctx, projectFromDb, s.ProjectMetadata(ctx, *projectFromDb, nil))
+ }
if derr != nil {
return []ProjectServiceInfo{}, errors.WrapIff(derr, "failed to load compose project in %s", projectFromDb.Path)
}
@@ -197,7 +200,18 @@ func (s *ProjectService) GetProjectContent(ctx context.Context, projectID string
}
composePath, composeErr := s.ResolveProjectComposeFile(ctx, proj)
- if composeErr != nil && !errors.Is(composeErr, common.ErrProjectComposeFileNotFound) {
+ switch {
+ case composeErr == nil, errors.Is(composeErr, common.ErrProjectComposeFileNotFound):
+ case errors.Is(composeErr, common.ErrProjectEnvUnreadable):
+ projectsDirectory, dirErr := s.GetProjectsDirectory(ctx)
+ if dirErr != nil {
+ slog.DebugContext(ctx, "failed to resolve projects directory for compose identification", "projectID", proj.ID, "error", dirErr)
+ }
+ composePath, composeErr = projects.DetectComposeFile(ctx, projectsDirectory, proj.Path)
+ if composeErr != nil && (!errors.Is(composeErr, common.ErrProjectEnvUnreadable) || composePath == "") {
+ return "", "", "", errors.WrapIf(composeErr, "failed to identify project compose file")
+ }
+ default:
return "", "", "", composeErr
}
@@ -267,10 +281,15 @@ func (s *ProjectService) GetProjectDetails(ctx context.Context, projectID string
// configuration problem is diagnosable.
composeSelection, selErr := projects.ComposeFileEnvSelection(ctx, projectsDir, proj.Path)
if selErr != nil {
- slog.WarnContext(ctx, "failed to resolve COMPOSE_FILE selection for project details", "projectID", proj.ID, "path", proj.Path, "error", selErr)
+ selLogLevel := slog.LevelWarn
+ if errors.Is(selErr, common.ErrProjectEnvUnreadable) {
+ selLogLevel = slog.LevelDebug
+ }
+ slog.Log(ctx, selLogLevel, "failed to resolve COMPOSE_FILE selection for project details", "projectID", proj.ID, "path", proj.Path, "error", selErr)
composeSelection = nil
}
resp.ComposeFiles = composeSelectionRelativePathsInternal(proj.Path, composeSelection)
+ resp.ConfigurationError = projects.CheckProjectEnvAccess(ctx, projectsDir, proj.Path)
if err := s.populateDetailsComposeContentInternal(ctx, proj, opts, composeSelection, &resp); err != nil {
return project.Details{}, err
@@ -818,6 +837,23 @@ func (s *ProjectService) enrichWithGitOpsInfo(ctx context.Context, proj *Project
func (s *ProjectService) enrichComposeDetailsInternal(ctx context.Context, proj *Project, opts project.DetailsOptions, resp *project.Details) {
composeFile, err := s.ResolveProjectComposeFile(ctx, proj)
if err != nil {
+ if !errors.Is(err, common.ErrProjectEnvUnreadable) {
+ return
+ }
+ // The env is unreadable, so only the compose file's identity is known:
+ // name it for the UI and skip every enrichment that needs interpolation.
+ projectsDirectory, dirErr := s.GetProjectsDirectory(ctx)
+ if dirErr != nil {
+ slog.DebugContext(ctx, "failed to resolve projects directory for compose identification", "projectID", proj.ID, "error", dirErr)
+ }
+ identified, detectErr := projects.DetectComposeFile(ctx, projectsDirectory, proj.Path)
+ if detectErr != nil && (!errors.Is(detectErr, common.ErrProjectEnvUnreadable) || identified == "") {
+ slog.WarnContext(ctx, "failed to identify project compose file", "projectID", proj.ID, "error", detectErr)
+ return
+ }
+ if identified != "" {
+ resp.ComposeFileName = filepath.Base(identified)
+ }
return
}
resp.ComposeFileName = filepath.Base(composeFile)
diff --git a/backend/internal/project/project_lifecycle.go b/backend/internal/project/project_lifecycle.go
index 6d540c067..65c94fe19 100644
--- a/backend/internal/project/project_lifecycle.go
+++ b/backend/internal/project/project_lifecycle.go
@@ -236,6 +236,9 @@ func (s *ProjectService) DeployProject(ctx context.Context, projectID string, us
if err := ensureProjectMutableInternal(projectFromDb); err != nil {
return err
}
+ if _, err := s.ResolveProjectComposeFile(ctx, projectFromDb); err != nil {
+ return err
+ }
if err := s.updateProjectStatusInternal(ctx, projectID, ProjectStatusDeploying); err != nil {
return errors.WrapIf(err, "failed to update project status to deploying")
@@ -518,6 +521,10 @@ func (s *ProjectService) RedeployProject(ctx context.Context, projectID string,
return err
}
+ if _, err := s.ResolveProjectComposeFile(ctx, proj); err != nil {
+ return err
+ }
+
disabled := s.projectRedeployDisabledInternal(ctx, *proj)
if disabled {
return errors.New("arcane cannot redeploy itself; use the system upgrade flow (Settings -> Updates) instead")
@@ -552,7 +559,7 @@ func (s *ProjectService) projectRedeployDisabledInternal(ctx context.Context, pr
containersByProject := groupComposeContainersByProjectInternal(containers)
currentContainerID, currentContainerErr := cgroup.CurrentContainerID()
- for _, containerSummary := range lookupProjectContainers(proj, containersByProject) {
+ for _, containerSummary := range lookupProjectContainersInternal(proj, containersByProject) {
if labels.ShouldDisableArcaneServerRedeploy(containerSummary.Labels, containerSummary.ID, currentContainerID, currentContainerErr) {
return true
}
@@ -649,6 +656,9 @@ func (s *ProjectService) RestartProject(ctx context.Context, projectID string, s
if err != nil {
return err
}
+ if _, err := s.ResolveProjectComposeFile(ctx, proj); err != nil {
+ return err
+ }
if err := s.updateProjectStatusInternal(ctx, projectID, ProjectStatusRestarting); err != nil {
return errors.WrapIf(err, "failed to update project status to restarting")
diff --git a/backend/internal/project/project_listing.go b/backend/internal/project/project_listing.go
index 0aa788819..fdea77460 100644
--- a/backend/internal/project/project_listing.go
+++ b/backend/internal/project/project_listing.go
@@ -8,10 +8,12 @@ import (
"log/slog"
"maps"
"os"
+ "path/filepath"
"strings"
"time"
"emperror.dev/errors"
+ composeapi "github.com/docker/compose/v5/pkg/api"
"github.com/getarcaneapp/arcane/backend/v2/internal/image"
dockerutil "github.com/getarcaneapp/arcane/backend/v2/pkg/dockerutil"
@@ -58,18 +60,87 @@ func groupComposeContainersByProjectInternal(containers []container.Summary) map
return containersByProject
}
-// lookupProjectContainers returns containers matched to a project, trying the
-// normalized directory name first and falling back to the effective compose
-// project name (from COMPOSE_PROJECT_NAME) when it differs.
-func lookupProjectContainers(p Project, containersByProject map[string][]container.Summary) []container.Summary {
+// lookupProjectContainersInternal matches project names first, then the working
+// directory if it identifies exactly one Compose project group.
+func lookupProjectContainersInternal(p Project, containersByProject map[string][]container.Summary) []container.Summary {
normName := projects.NormalizeProjectName(p.Name)
if c := containersByProject[normName]; len(c) > 0 {
return c
}
if p.ComposeProjectName != nil && *p.ComposeProjectName != normName {
- return containersByProject[*p.ComposeProjectName]
+ if c := containersByProject[*p.ComposeProjectName]; len(c) > 0 {
+ return c
+ }
+ }
+ if p.Path == "" {
+ return nil
+ }
+ projectPath := filepath.Clean(p.Path)
+ var matched []container.Summary
+ var matchedProjectName string
+ for projectName, containers := range containersByProject {
+ for _, c := range containers {
+ workingDir := c.Labels[composeapi.WorkingDirLabel]
+ if workingDir != "" && filepath.Clean(workingDir) == projectPath {
+ if matched != nil && matchedProjectName != projectName {
+ return nil
+ }
+ matchedProjectName = projectName
+ matched = append(matched, c)
+ }
+ }
}
- return nil
+ return matched
+}
+
+func projectServiceInfoFromContainerInternal(ctx context.Context, c container.Summary, meta projects.ArcaneComposeMetadata, currentContainerID string, currentContainerErr error) ProjectServiceInfo {
+ svcName := dockerutil.ComposeServiceLabel(c.Labels)
+
+ var health *string
+ statusLower := strings.ToLower(c.Status)
+ switch {
+ case strings.Contains(statusLower, "(healthy)"):
+ health = new("healthy")
+ case strings.Contains(statusLower, "(unhealthy)"):
+ health = new("unhealthy")
+ case strings.Contains(statusLower, "(starting)"):
+ health = new("starting")
+ }
+
+ resolvedIcon := iconcatalog.Resolve(IconCatalogForContext(ctx), iconcatalog.FirstNonEmpty(
+ projects.FindArcaneIconSet(c.Labels),
+ meta.ServiceIconSets[svcName],
+ meta.ProjectIcon,
+ ))
+ return ProjectServiceInfo{
+ Name: svcName,
+ Image: c.Image,
+ Status: string(c.State),
+ ContainerID: c.ID,
+ ContainerName: dockerutil.ContainerNameFromNames(c.Names),
+ Ports: projects.FormatDockerPorts(c.Ports),
+ Health: health,
+ IconLightURL: resolvedIcon.IconLightURL,
+ IconDarkURL: resolvedIcon.IconDarkURL,
+ Labels: c.Labels,
+ RedeployDisabled: labels.ShouldDisableArcaneServerRedeploy(c.Labels, c.ID, currentContainerID, currentContainerErr),
+ }
+}
+
+// projectServicesFromContainersInternal derives runtime services from labeled
+// containers for projects whose Compose file cannot be loaded.
+func (s *ProjectService) projectServicesFromContainersInternal(ctx context.Context, proj *Project, meta projects.ArcaneComposeMetadata) ([]ProjectServiceInfo, error) {
+ containers, err := s.listGlobalComposeContainersInternal(ctx)
+ if err != nil {
+ return nil, err
+ }
+ matched := lookupProjectContainersInternal(*proj, groupComposeContainersByProjectInternal(containers))
+ currentContainerID, currentContainerErr := cgroup.CurrentContainerID()
+ services := make([]ProjectServiceInfo, 0, len(matched))
+ for _, c := range matched {
+ services = append(services, projectServiceInfoFromContainerInternal(ctx, c, meta, currentContainerID, currentContainerErr))
+ }
+ return services, nil
}
func (s *ProjectService) ListAllProjects(ctx context.Context) ([]Project, error) {
@@ -156,7 +227,7 @@ func (s *ProjectService) GetProjectStatusCounts(ctx context.Context) (folderCoun
// 3. Calculate status for each project
for _, p := range activeProjects {
- projectContainers := lookupProjectContainers(p, containersByProject)
+ projectContainers := lookupProjectContainersInternal(p, containersByProject)
// Convert to ProjectServiceInfo (minimal needed for calculateProjectStatus)
var services []ProjectServiceInfo
@@ -785,7 +856,7 @@ func (s *ProjectService) CountProjectsWithPendingUpdates(ctx context.Context, al
containersByProject := groupComposeContainersByProjectInternal(allContainers)
for i, proj := range activeProjects {
details[i].ID = proj.ID
- for _, c := range lookupProjectContainers(proj, containersByProject) {
+ for _, c := range lookupProjectContainersInternal(proj, containersByProject) {
details[i].RuntimeServices = append(details[i].RuntimeServices, project.RuntimeService{Name: dockerutil.ComposeServiceLabel(c.Labels), ContainerID: c.ID, Image: c.Image, ContainerLabels: c.Labels})
}
}
@@ -869,6 +940,7 @@ func (s *ProjectService) fetchProjectStatusConcurrently(ctx context.Context, pro
results[i].HasBuildDirective = p.BuildImageRefsJSON != nil && len(projects.ParseImageRefsJSON(*p.BuildImageRefsJSON)) > 0
applyResolvedProjectIconInternal(&results[i], iconcatalog.Resolve(IconCatalogForContext(ctx), metas[i].ProjectIcon))
results[i].URLs = metas[i].ProjectURLS
+ results[i].ConfigurationError = projects.CheckProjectEnvAccess(ctx, projectsDir, p.Path)
results[i].Status = string(ProjectStatusUnknown)
}
return results
@@ -919,52 +991,18 @@ func (s *ProjectService) mapProjectToDto(ctx context.Context, projectsDir string
resp.HasBuildDirective = p.BuildImageRefsJSON != nil && len(projects.ParseImageRefsJSON(*p.BuildImageRefsJSON)) > 0
applyResolvedProjectIconInternal(&resp, iconcatalog.Resolve(IconCatalogForContext(ctx), meta.ProjectIcon))
resp.URLs = meta.ProjectURLS
+ resp.ConfigurationError = projects.CheckProjectEnvAccess(ctx, projectsDir, p.Path)
- projectContainers := lookupProjectContainers(p, containersByProject)
+ projectContainers := lookupProjectContainersInternal(p, containersByProject)
services := make([]ProjectServiceInfo, 0, len(projectContainers))
for _, c := range projectContainers {
- svcName := dockerutil.ComposeServiceLabel(c.Labels)
- state := c.State // "running", "exited", etc.
-
- // Parse health from Status string if possible
- var health *string
- statusLower := strings.ToLower(c.Status)
- switch {
- case strings.Contains(statusLower, "(healthy)"):
- health = new("healthy")
- case strings.Contains(statusLower, "(unhealthy)"):
- health = new("unhealthy")
- case strings.Contains(statusLower, "(starting)"):
- health = new("starting")
- }
-
- containerName := dockerutil.ContainerNameFromNames(c.Names)
-
- redeployDisabled := labels.ShouldDisableArcaneServerRedeploy(c.Labels, c.ID, currentContainerID, currentContainerErr)
- if redeployDisabled {
+ service := projectServiceInfoFromContainerInternal(ctx, c, meta, currentContainerID, currentContainerErr)
+ if service.RedeployDisabled {
resp.RedeployDisabled = true
}
-
- resolvedIcon := iconcatalog.Resolve(IconCatalogForContext(ctx), iconcatalog.FirstNonEmpty(
- projects.FindArcaneIconSet(c.Labels),
- meta.ServiceIconSets[svcName],
- meta.ProjectIcon,
- ))
- services = append(services, ProjectServiceInfo{
- Name: svcName,
- Image: c.Image,
- Status: string(state),
- ContainerID: c.ID,
- ContainerName: containerName,
- Ports: projects.FormatDockerPorts(c.Ports),
- Health: health,
- IconLightURL: resolvedIcon.IconLightURL,
- IconDarkURL: resolvedIcon.IconDarkURL,
- Labels: c.Labels,
- RedeployDisabled: redeployDisabled,
- })
+ services = append(services, service)
}
_, runningCount := getServiceCounts(services)
diff --git a/backend/internal/project/project_sync.go b/backend/internal/project/project_sync.go
index dd6d4104a..0f913d334 100644
--- a/backend/internal/project/project_sync.go
+++ b/backend/internal/project/project_sync.go
@@ -186,6 +186,10 @@ func (s *ProjectService) upsertProjectForDir(ctx context.Context, dirName, dirPa
First(&existing).Error
composeMetadata, serviceCountErr := s.loadComposeMetadataForSyncInternal(ctx, dirPath, dirName)
+ serviceCountLogLevel := slog.LevelWarn
+ if errors.Is(serviceCountErr, common.ErrProjectEnvUnreadable) {
+ serviceCountLogLevel = slog.LevelDebug
+ }
if errors.Is(err, gorm.ErrRecordNotFound) {
// Create a minimal project entry
@@ -205,7 +209,7 @@ func (s *ProjectService) upsertProjectForDir(ctx context.Context, dirName, dirPa
"path", dirPath,
"reason", reason)
if serviceCountErr != nil {
- slog.WarnContext(ctx, "failed to read compose service count during project discovery", "project", dirName, "path", dirPath, "error", serviceCountErr)
+ slog.Log(ctx, serviceCountLogLevel, "failed to read compose service count during project discovery", "project", dirName, "path", dirPath, "error", serviceCountErr)
}
if cerr := s.db.WithContext(ctx).Create(proj).Error; cerr != nil {
return errors.WrapIff(cerr, "create project for %q failed", dirPath)
@@ -227,7 +231,7 @@ func (s *ProjectService) upsertProjectForDir(ctx context.Context, dirName, dirPa
if serviceCountErr == nil && existing.ServiceCount != composeMetadata.serviceCount {
updates["service_count"] = composeMetadata.serviceCount
} else if serviceCountErr != nil {
- slog.WarnContext(ctx, "failed to refresh compose service count during project sync", "projectID", existing.ID, "path", dirPath, "error", serviceCountErr)
+ slog.Log(ctx, serviceCountLogLevel, "failed to refresh compose service count during project sync", "projectID", existing.ID, "path", dirPath, "error", serviceCountErr)
}
if serviceCountErr == nil && mo.PointerToOption(existing.ComposeProjectName) != mo.PointerToOption(composeMetadata.composeProjectName) {
updates["compose_project_name"] = composeMetadata.composeProjectName
diff --git a/backend/internal/project/project_update.go b/backend/internal/project/project_update.go
index fe5bd465d..32a3a4973 100644
--- a/backend/internal/project/project_update.go
+++ b/backend/internal/project/project_update.go
@@ -60,6 +60,9 @@ func (s *ProjectService) UpdateProject(ctx context.Context, projectID string, na
if err := ensureProjectMutableInternal(&proj); err != nil {
return nil, err
}
+ if err := ensureProjectEnvReadableInternal(ctx, projectsDirectory, proj.Path); err != nil {
+ return nil, err
+ }
if err := s.ensureProjectStoppedForRenameInternal(ctx, &proj, name); err != nil {
return nil, err
}
@@ -97,6 +100,16 @@ func (s *ProjectService) UpdateProject(ctx context.Context, projectID string, na
return &proj, nil
}
+// ensureProjectEnvReadableInternal rejects operator-driven file writes into a
+// project whose .env exists but cannot be read by the runtime user.
+func ensureProjectEnvReadableInternal(ctx context.Context, projectsDirectory, projectPath string) error {
+ cfgErr := projects.CheckProjectEnvAccess(ctx, projectsDirectory, projectPath)
+ if cfgErr == nil || !cfgErr.BlocksOperations {
+ return nil
+ }
+ return common.Classify(common.ErrProjectEnvUnreadable, errors.Errorf("%s is not readable by the runtime user (uid %d, gid %d); fix its ownership/read permission or set PUID/PGID to a user that can read it", cfgErr.Path, cfgErr.UID, cfgErr.GID))
+}
+
// resolveAuthoritativeProjectNameInternal enforces that a top-level `name:` in
// the compose file is authoritative over the submitted project name. For
// name-only renames, it checks the compose file on disk so the lock can't be
diff --git a/backend/internal/project/service_test.go b/backend/internal/project/service_test.go
index 0af6419a6..128b137f9 100644
--- a/backend/internal/project/service_test.go
+++ b/backend/internal/project/service_test.go
@@ -4149,7 +4149,7 @@ func TestProjectService_MapProjectToDto_SetsRedeployDisabledFromRuntimeServices(
projectPath := filepath.Join(t.TempDir(), "arcane")
now := time.Now()
proj := Project{
- Name: "arcane",
+ Name: "arcane-directory",
Path: projectPath,
ServiceCount: 1,
ID: "project-arcane",
@@ -4227,6 +4227,7 @@ func TestProjectService_MapProjectToDto_SetsRedeployDisabledFromRuntimeServices(
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
service := &ProjectService{}
+ tt.labels[composeapi.WorkingDirLabel] = projectPath
details := service.mapProjectToDto(context.Background(), filepath.Dir(projectPath), proj, map[string][]container.Summary{
"arcane": {
{
@@ -4237,11 +4238,20 @@ func TestProjectService_MapProjectToDto_SetsRedeployDisabledFromRuntimeServices(
Names: []string{"/arcane-server"},
Labels: tt.labels,
},
+ {
+ ID: "unrelated-container",
+ Labels: map[string]string{
+ composeapi.ProjectLabel: "arcane",
+ composeapi.WorkingDirLabel: filepath.Join(filepath.Dir(projectPath), "unrelated"),
+ composeapi.ServiceLabel: "other",
+ },
+ },
},
}, tt.currentContainerID, tt.currentErr, projects.ArcaneComposeMetadata{})
require.Equal(t, tt.wantProject, details.RedeployDisabled)
require.Len(t, details.RuntimeServices, 1)
+ require.Equal(t, tt.containerID, details.RuntimeServices[0].ContainerID)
require.Equal(t, tt.wantService, details.RuntimeServices[0].RedeployDisabled)
})
}
diff --git a/backend/internal/project/workspace.go b/backend/internal/project/workspace.go
index 9714f87ff..59d19740d 100644
--- a/backend/internal/project/workspace.go
+++ b/backend/internal/project/workspace.go
@@ -156,6 +156,9 @@ func (s *ProjectService) UpdateProjectWorkspace(ctx context.Context, projectID s
if err != nil {
return nil, err
}
+ if err := ensureProjectEnvReadableInternal(ctx, projectsDirectory, proj.Path); err != nil {
+ return nil, err
+ }
backup, cleanup, err := s.prepareProjectWorkspaceBackupInternal(ctx, projectsDirectory, proj.Path, manifest.FileChanges)
if err != nil {
return nil, err
diff --git a/backend/pkg/fswatch/watcher.go b/backend/pkg/fswatch/watcher.go
index 087a806aa..a1e0d2601 100644
--- a/backend/pkg/fswatch/watcher.go
+++ b/backend/pkg/fswatch/watcher.go
@@ -280,7 +280,7 @@ func (fw *Watcher) handleEventInternal(ctx context.Context, event fsnotify.Event
// watch), the compose file's own Create event reaches this filter and passes
// via IsProjectFile.
func (fw *Watcher) shouldHandleEventInternal(event fsnotify.Event) bool {
- if !event.Has(fsnotify.Write) && !event.Has(fsnotify.Create) && !event.Has(fsnotify.Rename) && !event.Has(fsnotify.Remove) {
+ if !event.Has(fsnotify.Write) && !event.Has(fsnotify.Create) && !event.Has(fsnotify.Rename) && !event.Has(fsnotify.Remove) && !event.Has(fsnotify.Chmod) {
return false
}
return projects.IsProjectFile(filepath.Base(event.Name))
diff --git a/backend/pkg/projects/cache.go b/backend/pkg/projects/cache.go
index 172572e04..c22a5600e 100644
--- a/backend/pkg/projects/cache.go
+++ b/backend/pkg/projects/cache.go
@@ -113,6 +113,14 @@ func validComposeCacheEntryInternal(mtimes map[string]time.Time) bool {
if mtime.IsZero() || !info.ModTime().Equal(mtime) {
return false
}
+ // A chmod does not bump mtime, so confirm the file is still readable.
+ file, err := os.Open(path)
+ if err != nil {
+ return false
+ }
+ if err := file.Close(); err != nil {
+ return false
+ }
}
return true
}
diff --git a/backend/pkg/projects/discovery.go b/backend/pkg/projects/discovery.go
index a2c7a0900..658b5d418 100644
--- a/backend/pkg/projects/discovery.go
+++ b/backend/pkg/projects/discovery.go
@@ -11,6 +11,7 @@ import (
"emperror.dev/errors"
"github.com/compose-spec/compose-go/v2/loader"
+ "github.com/getarcaneapp/arcane/backend/v2/internal/common"
"go.yaml.in/yaml/v4"
)
@@ -132,7 +133,16 @@ func walkProjectDirectoriesInternal(ctx context.Context, root, path string, isRo
// The projects root directory itself is exempt — we always descend into it
// so siblings under the root are all discovered, even if the root happens
// to contain its own compose file.
- if _, err := DetectComposeFile(ctx, root, path); err == nil {
+ switch composePath, err := DetectComposeFile(ctx, root, path); {
+ case err == nil, errors.Is(err, common.ErrProjectEnvUnreadable) && composePath != "":
+ if err != nil {
+ slog.Warn("Discovered project with an unreadable .env",
+ "path", path,
+ "envFile", filepath.Join(path, EffectiveEnvFileName),
+ "uid", os.Geteuid(),
+ "gid", os.Getegid(),
+ "error", err)
+ }
*discovered = append(*discovered, DiscoveredProjectDir{
DirName: filepath.Base(path),
Path: path,
@@ -140,6 +150,9 @@ func walkProjectDirectoriesInternal(ctx context.Context, root, path string, isRo
if !isRoot {
return nil
}
+ case errors.Is(err, common.ErrComposeFileNotFound):
+ default:
+ slog.Warn("Skipping undetectable project directory during discovery", "path", path, "error", err)
}
if maxDepth > 0 && currentDepth >= maxDepth {
diff --git a/backend/pkg/projects/env.go b/backend/pkg/projects/env.go
index 411a043af..2642fd7fb 100644
--- a/backend/pkg/projects/env.go
+++ b/backend/pkg/projects/env.go
@@ -18,6 +18,7 @@ import (
"github.com/compose-spec/compose-go/v2/consts"
"github.com/compose-spec/compose-go/v2/dotenv"
"github.com/getarcaneapp/arcane/backend/v2/internal/common"
+ projecttypes "github.com/getarcaneapp/arcane/types/v2/project"
"github.com/samber/hot"
"go.getarcane.app/acfs"
)
@@ -128,9 +129,12 @@ func (l *EnvLoader) LoadEnvironment(ctx context.Context) (envMap EnvMap, injecti
} else {
projectEnvPath := filepath.Join(l.workdir, EffectiveEnvFileName)
if err := l.loadAndMergeProjectEnv(ctx, projectEnvPath, envMap, injectionVars); err != nil {
- if errors.Is(err, os.ErrNotExist) {
+ switch {
+ case errors.Is(err, os.ErrNotExist):
slog.DebugContext(ctx, "Project .env file does not exist", "path", projectEnvPath)
- } else {
+ case errors.Is(err, os.ErrPermission):
+ return envMap, injectionVars, common.Classify(common.ErrProjectEnvUnreadable, errors.WrapIff(err, "%s is not readable by the runtime user (uid %d, gid %d); fix its ownership/read permission or set PUID/PGID to a user that can read it", projectEnvPath, os.Geteuid(), os.Getegid()))
+ default:
slog.WarnContext(ctx, "Failed to load project env", "path", projectEnvPath, "error", err)
}
}
@@ -273,7 +277,15 @@ func validEnvFileCacheEntryInternal(entry envFileCacheEntry) bool {
if info.IsDir() {
return false
}
- return entry.exists && info.ModTime().Equal(entry.mtime)
+ if !entry.exists || !info.ModTime().Equal(entry.mtime) {
+ return false
+ }
+ // A chmod does not bump mtime, so confirm the file is still readable.
+ file, err := os.Open(entry.path)
+ if err != nil {
+ return false
+ }
+ return file.Close() == nil
}
func parseProjectEnvFileExistingInternal(path string, contextEnv EnvMap) (EnvMap, error) {
@@ -570,6 +582,40 @@ func BuildOverrideEnvContent(gitContent, effectiveContent string) (string, error
return formatEnvMapInternal(override), nil
}
+// CheckProjectEnvAccess reports a configuration error when the runtime user
+// lacks permission to open dir's .env or traverse its path.
+func CheckProjectEnvAccess(ctx context.Context, projectsDir, dir string) *projecttypes.ConfigurationError {
+ envPath := filepath.Join(dir, EffectiveEnvFileName)
+ file, err := os.Open(envPath)
+ if err == nil {
+ if closeErr := file.Close(); closeErr != nil {
+ slog.WarnContext(ctx, "failed to close project env access probe", "path", envPath, "error", closeErr)
+ }
+ return nil
+ }
+ if !errors.Is(err, os.ErrPermission) {
+ return nil
+ }
+
+ disabled := false
+ if strings.TrimSpace(projectsDir) != "" {
+ globalEnv, globalErr := ParseProjectEnvFile(filepath.Join(projectsDir, GlobalEnvFileName), make(EnvMap))
+ if globalErr != nil {
+ slog.DebugContext(ctx, "Failed to read global env while checking project env access", "path", projectsDir, "error", globalErr)
+ } else {
+ disabled = parseComposeBoolInternal(globalEnv, consts.ComposeDisableDefaultEnvFile)
+ }
+ }
+
+ return &projecttypes.ConfigurationError{
+ Code: common.ConfigurationErrorCodeEnvFileUnreadable,
+ Path: envPath,
+ UID: os.Geteuid(),
+ GID: os.Getegid(),
+ BlocksOperations: !disabled,
+ }
+}
+
func ReadProjectEnvState(projectPath string) (ProjectEnvState, error) {
effectiveContent, hasEffective, effectiveUnreadable, err := readOptionalProjectFileInternal(projectPath, EffectiveEnvFileName)
if err != nil {
@@ -820,8 +866,12 @@ func ComposeFileEnvSelection(ctx context.Context, projectsDir, dir string) ([]st
// COMPOSE_DISABLE_ENV_FILE skips the project .env; it is read only from the
// sources merged so far (.env.global), matching LoadEnvironment.
if !parseComposeBoolInternal(envMap, consts.ComposeDisableDefaultEnvFile) {
- projectEnv, err := ParseProjectEnvFile(filepath.Join(dir, EffectiveEnvFileName), envMap)
+ projectEnvPath := filepath.Join(dir, EffectiveEnvFileName)
+ projectEnv, err := ParseProjectEnvFile(projectEnvPath, envMap)
if err != nil {
+ if errors.Is(err, os.ErrPermission) {
+ return nil, common.Classify(common.ErrProjectEnvUnreadable, errors.WrapIff(err, "%s is not readable by the runtime user (uid %d, gid %d); fix its ownership/read permission or set PUID/PGID to a user that can read it", projectEnvPath, os.Geteuid(), os.Getegid()))
+ }
return nil, err
}
maps.Copy(envMap, projectEnv)
diff --git a/backend/pkg/projects/fs_util.go b/backend/pkg/projects/fs_util.go
index 9c9d7f82c..387c370af 100644
--- a/backend/pkg/projects/fs_util.go
+++ b/backend/pkg/projects/fs_util.go
@@ -108,7 +108,7 @@ func isBackendModuleRoot(path string) bool {
func ReadProjectFiles(ctx context.Context, projectPath, composePath string) (composeContent, envContent string, err error) {
if strings.TrimSpace(composePath) == "" {
detected, derr := DetectComposeFile(ctx, "", projectPath)
- if derr != nil && !errors.Is(derr, common.ErrComposeFileNotFound) {
+ if derr != nil && !errors.Is(derr, common.ErrComposeFileNotFound) && (!errors.Is(derr, common.ErrProjectEnvUnreadable) || detected == "") {
return "", "", derr
}
composePath = detected
diff --git a/backend/pkg/projects/load.go b/backend/pkg/projects/load.go
index ecf77e3c1..e48f61c42 100644
--- a/backend/pkg/projects/load.go
+++ b/backend/pkg/projects/load.go
@@ -68,10 +68,18 @@ func stripTrailingProjectCounterInternal(name string) string {
// DetectComposeFile returns the base compose file for dir. COMPOSE_FILE in the
// project's .env takes precedence over standard detection, mirroring `docker
// compose`; projectsDir locates .env.global for the COMPOSE_DISABLE_ENV_FILE
-// check and may be empty where no projects directory applies.
+// check and may be empty where no projects directory applies. An unreadable
+// project .env falls back to filename detection and returns the found path
+// together with a common.ErrProjectEnvUnreadable error: that pairing is an
+// identification-only result for discovery and diagnostics, and callers that
+// check err != nil remain strict and must keep doing so.
func DetectComposeFile(ctx context.Context, projectsDir, dir string) (string, error) {
+ var envErr error
if files, err := ComposeFileEnvSelection(ctx, projectsDir, dir); err != nil {
- return "", err
+ if !errors.Is(err, common.ErrProjectEnvUnreadable) {
+ return "", err
+ }
+ envErr = err
} else if len(files) > 0 {
return files[0], nil
}
@@ -82,7 +90,7 @@ func DetectComposeFile(ctx context.Context, projectsDir, dir string) (string, er
for _, filename := range composeFileCandidates {
composePath := filepath.Join(dir, filename)
if info, err := os.Stat(composePath); err == nil && !info.IsDir() {
- return composePath, nil
+ return composePath, envErr
}
}
@@ -138,17 +146,17 @@ func DetectComposeFile(ctx context.Context, projectsDir, dir string) (string, er
switch {
case len(dirMatchedCandidates) == 1:
- return dirMatchedCandidates[0], nil
+ return dirMatchedCandidates[0], envErr
case len(dirMatchedCandidates) > 1:
return "", errors.Errorf("multiple custom compose files found in %q", dir)
case len(composeNamedCandidates) == 1:
- return composeNamedCandidates[0], nil
+ return composeNamedCandidates[0], envErr
case len(composeNamedCandidates) > 1:
return "", errors.Errorf("multiple custom compose files found in %q", dir)
case len(customCandidates) == 1:
- return customCandidates[0], nil
+ return customCandidates[0], envErr
case len(customCandidates) > 1:
return "", errors.Errorf("multiple custom compose files found in %q", dir)
@@ -348,6 +356,9 @@ func LoadComposeProject(
// Load full environment (process + global + project .env) for service injection
fullEnvMap, injectionVars, err := envLoader.LoadEnvironment(ctx)
if err != nil {
+ if errors.Is(err, common.ErrProjectEnvUnreadable) {
+ return nil, err
+ }
slog.WarnContext(ctx, "Failed to load environment", "error", err)
}
diff --git a/frontend/messages/en.json b/frontend/messages/en.json
index 24ba65419..86dbff90a 100644
--- a/frontend/messages/en.json
+++ b/frontend/messages/en.json
@@ -1336,6 +1336,10 @@
"compose_override_remove": "Remove override",
"compose_multiple_files_title": "Multiple compose files",
"compose_multiple_files_description": "This project deploys the compose files below, selected by COMPOSE_FILE in its .env. Files other than the base are edited in the Workspace view.",
+ "env_file_unreadable_title": "Environment file unreadable",
+ "env_file_unreadable_blocked": "Arcane cannot read {path} (uid {uid}, gid {gid}). Compose actions are disabled until you fix the file's ownership or read permission, or set PUID/PGID to match it.",
+ "env_file_unreadable_ignored": "Arcane cannot read {path} (uid {uid}, gid {gid}). This project has its .env disabled, so actions still work, but the file cannot be shown or edited here.",
+ "env_file_unavailable": "The .env file cannot be read, so it is not shown here.",
"compose_no_services_found": "No services found for this project",
"compose_service_not_created": "Not created",
"compose_name_change_not_allowed": "Project name cannot be changed while running. Please stop the project first.",
diff --git a/frontend/src/lib/components/action-buttons.svelte b/frontend/src/lib/components/action-buttons.svelte
index 183442892..7e97e8703 100644
--- a/frontend/src/lib/components/action-buttons.svelte
+++ b/frontend/src/lib/components/action-buttons.svelte
@@ -60,6 +60,8 @@
refreshLoading = $bindable(false),
hasBuildDirective = false,
disableRedeploy = false,
+ disabled = false,
+ disabledReason,
onRefresh,
beforeRemoveActions,
beforeRemoveMenuItems
@@ -79,6 +81,8 @@
refreshLoading?: boolean;
hasBuildDirective?: boolean;
disableRedeploy?: boolean;
+ disabled?: boolean;
+ disabledReason?: string;
onRefresh?: () => void | Promise<void>;
beforeRemoveActions?: Snippet<[ArcaneButtonSize, boolean, boolean]>;
beforeRemoveMenuItems?: Snippet<[boolean]>;
@@ -550,7 +554,9 @@
{#snippet RedeployActionButton(size: 'default' | 'icon' = 'default', showLabel = true)}
{#if canRedeploy}
- {#if disableRedeploy}
+ {#if disabled}
+ <ArcaneButton action="redeploy" {size} {showLabel} disabled title={disabledReason} />
+ {:else if disableRedeploy}
<span class="inline-flex" title={m.common_redeploy_disabled_arcane_self()}>
<ArcaneButton action="redeploy" {size} {showLabel} disabled />
</span>
@@ -560,20 +566,34 @@
action="redeploy"
{size}
{showLabel}
+ {disabled}
+ title={disabledReason}
onclick={() => confirmAction('redeploy')}
loading={uiLoading.redeploy}
/>
- {@render WatchDropdown(() => confirmRedeploy(true), !!uiLoading.redeploy, size, true)}
+ {@render WatchDropdown(() => confirmRedeploy(true), disabled || !!uiLoading.redeploy, size, true)}
</ButtonGroup.Root>
{:else}
- <ArcaneButton action="redeploy" {size} {showLabel} onclick={() => confirmAction('redeploy')} loading={uiLoading.redeploy} />
+ <ArcaneButton
+ action="redeploy"
+ {size}
+ {showLabel}
+ {disabled}
+ title={disabledReason}
+ onclick={() => confirmAction('redeploy')}
+ loading={uiLoading.redeploy}
+ />
{/if}
{/if}
{/snippet}
{#snippet RedeployMenuItem()}
{#if canRedeploy}
- {#if disableRedeploy}
+ {#if disabled}
+ <DropdownMenu.Item disabled title={disabledReason}>
+ {m.common_redeploy()}
+ </DropdownMenu.Item>
+ {:else if disableRedeploy}
<DropdownMenu.Item disabled title={m.common_redeploy_disabled_arcane_self()}>
{m.common_redeploy()}
</DropdownMenu.Item>
@@ -588,11 +608,20 @@
{#snippet DesktopActions(size: 'default' | 'icon', showLabel: boolean)}
{#if !isRunning && canStart}
{#if type === 'container'}
- <ArcaneButton action="start" {size} {showLabel} onclick={() => handleStart()} loading={uiLoading.start} />
+ <ArcaneButton
+ action="start"
+ {size}
+ {showLabel}
+ {disabled}
+ title={disabledReason}
+ onclick={() => handleStart()}
+ loading={uiLoading.start}
+ />
{:else}
<DeploySplitButton
{size}
{showLabel}
+ {disabled}
customLabel={deployButtonLabel}
onDeploy={() => handleDeploy()}
onDeployWatch={() => handleDeploy(undefined, true)}
@@ -607,13 +636,23 @@
action="stop"
{size}
{showLabel}
+ {disabled}
+ title={disabledReason}
customLabel={type === 'project' ? m.common_down() : undefined}
onclick={() => handleStop()}
loading={uiLoading.stop}
/>
{/if}
{#if canRestart}
- <ArcaneButton action="restart" {size} {showLabel} onclick={() => handleRestart()} loading={uiLoading.restart} />
+ <ArcaneButton
+ action="restart"
+ {size}
+ {showLabel}
+ {disabled}
+ title={disabledReason}
+ onclick={() => handleRestart()}
+ loading={uiLoading.restart}
+ />
{/if}
{/if}
@@ -628,13 +667,29 @@
{#if type === 'project'}
{#if projectHasBuildDirective && canBuild}
- <ArcaneButton action="build" {size} {showLabel} onclick={() => handleProjectBuild()} loading={uiLoading.build} />
+ <ArcaneButton
+ action="build"
+ {size}
+ {showLabel}
+ {disabled}
+ title={disabledReason}
+ onclick={() => handleProjectBuild()}
+ loading={uiLoading.build}
+ />
{/if}
{#if canPull}
<ButtonGroup.Root>
- <ArcaneButton action="pull" {size} {showLabel} onclick={() => handleProjectPull()} loading={uiLoading.pull} />
- {@render WatchDropdown(() => handleProjectPull(true), !!uiLoading.pull, size)}
+ <ArcaneButton
+ action="pull"
+ {size}
+ {showLabel}
+ {disabled}
+ title={disabledReason}
+ onclick={() => handleProjectPull()}
+ loading={uiLoading.pull}
+ />
+ {@render WatchDropdown(() => handleProjectPull(true), disabled || !!uiLoading.pull, size)}
</ButtonGroup.Root>
{/if}
{/if}
@@ -670,22 +725,22 @@
<DropdownMenu.Group>
{#if !isRunning && canStart}
{#if type === 'container'}
- <DropdownMenu.Item onclick={handleStart} disabled={uiLoading.start}>
+ <DropdownMenu.Item onclick={handleStart} disabled={disabled || uiLoading.start} title={disabledReason}>
{m.common_start()}
</DropdownMenu.Item>
{:else}
- <DropdownMenu.Item onclick={() => handleDeploy()} disabled={uiLoading.start}>
+ <DropdownMenu.Item onclick={() => handleDeploy()} disabled={disabled || uiLoading.start} title={disabledReason}>
{deployButtonLabel}
</DropdownMenu.Item>
{/if}
{:else if isRunning}
{#if canStop}
- <DropdownMenu.Item onclick={handleStop} disabled={uiLoading.stop}>
+ <DropdownMenu.Item onclick={handleStop} disabled={disabled || uiLoading.stop} title={disabledReason}>
{type === 'project' ? m.common_down() : m.common_stop()}
</DropdownMenu.Item>
{/if}
{#if canRestart}
- <DropdownMenu.Item onclick={handleRestart} disabled={uiLoading.restart}>
+ <DropdownMenu.Item onclick={handleRestart} disabled={disabled || uiLoading.restart} title={disabledReason}>
{m.common_restart()}
</DropdownMenu.Item>
{/if}
@@ -710,12 +765,12 @@
{#if type === 'project'}
{#if projectHasBuildDirective && canBuild}
- <DropdownMenu.Item onclick={handleProjectBuild} disabled={uiLoading.build}>
+ <DropdownMenu.Item onclick={handleProjectBuild} disabled={disabled || uiLoading.build} title={disabledReason}>
{m.build()}
</DropdownMenu.Item>
{/if}
{#if canPull}
- <DropdownMenu.Item onclick={() => handleProjectPull()} disabled={uiLoading.pull}>
+ <DropdownMenu.Item onclick={() => handleProjectPull()} disabled={disabled || uiLoading.pull} title={disabledReason}>
{m.pull()}
</DropdownMenu.Item>
{/if}
diff --git a/frontend/src/lib/components/deploy-split-button/deploy-split-button.svelte b/frontend/src/lib/components/deploy-split-button/deploy-split-button.svelte
index c4126a634..801061d57 100644
--- a/frontend/src/lib/components/deploy-split-button/deploy-split-button.svelte
+++ b/frontend/src/lib/components/deploy-split-button/deploy-split-button.svelte
@@ -11,6 +11,7 @@
size = 'default',
showLabel = true,
loading = false,
+ disabled = false,
customLabel,
onDeploy,
onDeployWatch
@@ -18,6 +19,7 @@
size?: ArcaneButtonSize;
showLabel?: boolean;
loading?: boolean;
+ disabled?: boolean;
customLabel?: string;
onDeploy: () => void | Promise<void>;
onDeployWatch?: () => void | Promise<void>;
@@ -25,7 +27,7 @@
</script>
<ButtonGroup.Root>
- <ArcaneButton action="deploy" {size} {showLabel} {loading} {customLabel} onclick={() => onDeploy?.()} />
+ <ArcaneButton action="deploy" {size} {showLabel} {loading} {disabled} {customLabel} onclick={() => onDeploy?.()} />
<DropdownMenu.Root>
<DropdownMenu.Trigger
@@ -35,7 +37,7 @@
size === 'lg' && 'size-10 rounded-xl'
)}
aria-label={m.common_open_menu()}
- disabled={loading}
+ disabled={loading || disabled}
onclick={(event) => event.stopPropagation()}
onpointerdown={(event) => event.stopPropagation()}
>
diff --git a/frontend/src/lib/types/swarm.ts b/frontend/src/lib/types/swarm.ts
index 31d977170..5025117a9 100644
--- a/frontend/src/lib/types/swarm.ts
+++ b/frontend/src/lib/types/swarm.ts
@@ -602,6 +602,14 @@ export interface ProjectTagOption {
color: ProjectTagColor;
}
+export type ProjectConfigurationError = {
+ code: 'env_file_unreadable';
+ path: string;
+ uid: number;
+ gid: number;
+ blocksOperations: boolean;
+};
+
export interface Project {
id: string;
name: string;
@@ -616,6 +624,7 @@ export interface Project {
serviceCount: string;
status: string;
statusReason?: string;
+ configurationError?: ProjectConfigurationError;
updatedAt: string;
createdAt: string;
isArchived?: boolean;
diff --git a/frontend/src/routes/(app)/projects/[projectId]/+page.svelte b/frontend/src/routes/(app)/projects/[projectId]/+page.svelte
index 47ae79600..0329a7eda 100644
--- a/frontend/src/routes/(app)/projects/[projectId]/+page.svelte
+++ b/frontend/src/routes/(app)/projects/[projectId]/+page.svelte
@@ -224,6 +224,14 @@
const serverName = $derived(project?.name ?? '');
const serverComposeContent = $derived(project?.composeContent ?? '');
const serverEnvContent = $derived(project?.envContent ?? '');
+
+ const configurationError = $derived(project?.configurationError);
+ const composeActionsBlocked = $derived(!!configurationError?.blocksOperations);
+ const configurationErrorMessage = $derived.by(() => {
+ if (!configurationError) return undefined;
+ const params = { path: configurationError.path, uid: configurationError.uid, gid: configurationError.gid };
+ return configurationError.blocksOperations ? m.env_file_unreadable_blocked(params) : m.env_file_unreadable_ignored(params);
+ });
const serverOverrideContent = $derived(project?.overrideContent ?? '');
const serverIncludeFiles = $derived.by(() =>
Object.fromEntries(
@@ -260,7 +268,7 @@
effectiveName !== serverName ||
inputs.composeContent.value !== serverComposeContent ||
inputs.overrideContent.value !== serverOverrideContent ||
- inputs.envContent.value !== serverEnvContent ||
+ (!configurationError && inputs.envContent.value !== serverEnvContent) ||
Object.entries(includeFilesState).some(([relativePath, content]) => content !== serverIncludeFiles[relativePath]) ||
projectWorkspaceChanges.length > 0 ||
changedProjectWorkspacePaths.length > 0
@@ -278,10 +286,10 @@
project?.status !== 'running' &&
project?.status !== 'partially running'
);
- let canEditCompose = $derived(canUpdateProject && !project?.isArchived && !isGitOpsManaged);
+ let canEditCompose = $derived(canUpdateProject && !project?.isArchived && !isGitOpsManaged && !composeActionsBlocked);
// Override edits are blocked for GitOps-managed projects, mirroring canEditCompose.
- let canEditOverride = $derived(canUpdateProject && !project?.isArchived && !isGitOpsManaged);
- let canEditEnv = $derived(canUpdateProject && !project?.isArchived);
+ let canEditOverride = $derived(canUpdateProject && !project?.isArchived && !isGitOpsManaged && !composeActionsBlocked);
+ let canEditEnv = $derived(canUpdateProject && !project?.isArchived && !configurationError);
// GitOps-managed projects keep workspace editing for operator-owned files
// (secret env files, bind-mounted configs); the backend rejects and marks
// read-only the paths the sync itself owns.
@@ -433,7 +441,7 @@
});
let composeHasChanges = $derived(inputs.composeContent.value !== serverComposeContent);
let overrideHasChanges = $derived(inputs.overrideContent.value !== serverOverrideContent);
- let envHasChanges = $derived(inputs.envContent.value !== serverEnvContent);
+ let envHasChanges = $derived(!configurationError && inputs.envContent.value !== serverEnvContent);
let changedIncludeFilePaths = $derived.by(() =>
Object.keys(includeFilesState).filter((relativePath) => includeFilesState[relativePath] !== serverIncludeFiles[relativePath])
);
@@ -447,7 +455,7 @@
)
);
- let canSave = $derived(canUpdateProject && !project?.isArchived && hasChanges && !hasAnyErrors);
+ let canSave = $derived(canUpdateProject && !project?.isArchived && hasChanges && !hasAnyErrors && !composeActionsBlocked);
const tabItems = $derived<TabItem[]>([
{
@@ -1462,6 +1470,7 @@
{#snippet projectComposeTab(project: Project)}
<Tabs.Content value="compose" class="h-full min-h-0">
<div class="flex h-full min-h-0 flex-col">
+ {@render configurationErrorNotice()}
{@render gitSourceNotice()}
{@render composeFilesNotice()}
<div class="mb-2 flex shrink-0 items-center justify-end gap-2">
@@ -1565,13 +1574,17 @@
{#snippet second()}
<div class="flex min-h-0 flex-1 flex-col">
- <CodePanel
- {...envPanelProps()}
- bind:open={envOpen}
- bind:value={inputs.envContent.value}
- bind:hasErrors={envHasErrors}
- bind:validationReady={envValidationReady}
- />
+ {#if configurationError}
+ {@render envUnavailable()}
+ {:else}
+ <CodePanel
+ {...envPanelProps()}
+ bind:open={envOpen}
+ bind:value={inputs.envContent.value}
+ bind:hasErrors={envHasErrors}
+ bind:validationReady={envValidationReady}
+ />
+ {/if}
</div>
{/snippet}
</ResizableSplit>
@@ -1719,53 +1732,56 @@
{#snippet projectServicesTab(project: Project)}
<Tabs.Content value="services" class="h-full min-h-0">
- {#if canViewProjectLogs}
- <div class="flex h-full min-h-0 flex-col overflow-hidden rounded-lg border border-border bg-card">
- <ResizableSplit
- class="h-full min-h-0 flex-1"
- variant="flush"
- firstClass="bg-muted/20 border-border flex min-h-0 flex-col border-b lg:border-r lg:border-b-0"
- secondClass="flex min-h-0 flex-col"
- minSize={200}
- maxSize={480}
- minSecondSize={360}
- defaultRatio={0.22}
- stackBelow={1024}
- ariaLabel={m.common_logs()}
- persistKey="arcane.project.services-split"
- persistStorage="local"
- >
- {#snippet first()}
- <ProjectServicesPanel
- services={project.runtimeServices}
- {projectId}
- updateInfoByRef={project.updateInfo?.updateInfoByRef}
- onRefresh={() => refreshProjectDetails()}
- />
- {/snippet}
- {#snippet second()}
- <div class="flex h-full min-h-0 flex-col overflow-hidden">
- {#key project.id}
- <ProjectsLogsPanel
- projectId={project.id}
- bind:autoScroll={autoScrollStackLogs}
- isRunning={project.status?.toLowerCase().includes('running')}
- />
- {/key}
- </div>
- {/snippet}
- </ResizableSplit>
- </div>
- {:else}
- <div class="flex h-full min-h-0 flex-col overflow-hidden rounded-lg border border-border bg-card">
- <ProjectServicesPanel
- services={project.runtimeServices}
- {projectId}
- updateInfoByRef={project.updateInfo?.updateInfoByRef}
- onRefresh={() => refreshProjectDetails()}
- />
- </div>
- {/if}
+ <div class="flex h-full min-h-0 flex-col">
+ {@render configurationErrorNotice()}
+ {#if canViewProjectLogs}
+ <div class="flex min-h-0 flex-1 flex-col overflow-hidden rounded-lg border border-border bg-card">
+ <ResizableSplit
+ class="h-full min-h-0 flex-1"
+ variant="flush"
+ firstClass="bg-muted/20 border-border flex min-h-0 flex-col border-b lg:border-r lg:border-b-0"
+ secondClass="flex min-h-0 flex-col"
+ minSize={200}
+ maxSize={480}
+ minSecondSize={360}
+ defaultRatio={0.22}
+ stackBelow={1024}
+ ariaLabel={m.common_logs()}
+ persistKey="arcane.project.services-split"
+ persistStorage="local"
+ >
+ {#snippet first()}
+ <ProjectServicesPanel
+ services={project.runtimeServices}
+ {projectId}
+ updateInfoByRef={project.updateInfo?.updateInfoByRef}
+ onRefresh={() => refreshProjectDetails()}
+ />
+ {/snippet}
+ {#snippet second()}
+ <div class="flex h-full min-h-0 flex-col overflow-hidden">
+ {#key project.id}
+ <ProjectsLogsPanel
+ projectId={project.id}
+ bind:autoScroll={autoScrollStackLogs}
+ isRunning={project.status?.toLowerCase().includes('running')}
+ />
+ {/key}
+ </div>
+ {/snippet}
+ </ResizableSplit>
+ </div>
+ {:else}
+ <div class="flex min-h-0 flex-1 flex-col overflow-hidden rounded-lg border border-border bg-card">
+ <ProjectServicesPanel
+ services={project.runtimeServices}
+ {projectId}
+ updateInfoByRef={project.updateInfo?.updateInfoByRef}
+ onRefresh={() => refreshProjectDetails()}
+ />
+ </div>
+ {/if}
+ </div>
</Tabs.Content>
{/snippet}
@@ -1867,6 +1883,16 @@
{/if}
{/snippet}
+{#snippet configurationErrorNotice()}
+ {#if configurationErrorMessage}
+ <Alert.Root variant="destructive" class="mb-4">
+ <AlertIcon class="size-4" />
+ <Alert.Title>{m.env_file_unreadable_title()}</Alert.Title>
+ <Alert.Description>{configurationErrorMessage}</Alert.Description>
+ </Alert.Root>
+ {/if}
+{/snippet}
+
{#snippet composeFilesNotice()}
{#if composeFiles.length > 1}
<Alert.Root variant="default" class="mb-4">
@@ -1885,6 +1911,14 @@
{/if}
{/snippet}
+{#snippet envUnavailable()}
+ <div
+ class="flex h-full min-h-0 flex-1 items-center justify-center rounded-lg border border-border px-4 text-center text-sm text-muted-foreground"
+ >
+ {m.env_file_unavailable()}
+ </div>
+{/snippet}
+
{#snippet activeWorkspaceEditor()}
{#key activeTreeTab}
{#if activeTreeTab === 'compose'}
@@ -1927,17 +1961,21 @@
/>
</div>
{:else if activeTreeTab === 'env'}
- <CodePanel
- variant="plain"
- {...envPanelProps()}
- bind:open={envOpen}
- bind:value={inputs.envContent.value}
- bind:hasErrors={envHasErrors}
- bind:validationReady={envValidationReady}
- bind:outlineOpen={treeOutlineOpen}
- bind:diffOpen={treeDiffOpen}
- bind:commandPaletteOpen={treeCommandPaletteOpen}
- />
+ {#if configurationError}
+ {@render envUnavailable()}
+ {:else}
+ <CodePanel
+ variant="plain"
+ {...envPanelProps()}
+ bind:open={envOpen}
+ bind:value={inputs.envContent.value}
+ bind:hasErrors={envHasErrors}
+ bind:validationReady={envValidationReady}
+ bind:outlineOpen={treeOutlineOpen}
+ bind:diffOpen={treeDiffOpen}
+ bind:commandPaletteOpen={treeCommandPaletteOpen}
+ />
+ {/if}
{:else if activeTreeTab.startsWith('file:')}
{@const relativePath = activeTreeTab.slice(5)}
{@render workspaceFileEditor(relativePath)}
@@ -2077,7 +2115,7 @@
updateInfo={project.updateInfo}
onCheck={handleCheckProjectUpdates}
checking={checkProjectUpdatesMutation.isPending}
- disabled={!!project.isArchived}
+ disabled={!!project.isArchived || composeActionsBlocked}
/>
</div>
@@ -2172,6 +2210,8 @@
{hasBuildDirective}
desktopVariant="adaptive"
disableRedeploy={!!project.redeployDisabled}
+ disabled={composeActionsBlocked}
+ disabledReason={composeActionsBlocked ? m.env_file_unreadable_title() : undefined}
bind:startLoading={isLoading.deploying}
bind:stopLoading={isLoading.stopping}
bind:restartLoading={isLoading.restarting}
diff --git a/frontend/src/routes/(app)/projects/projects-table.svelte b/frontend/src/routes/(app)/projects/projects-table.svelte
index 233fa420e..ee849d57a 100644
--- a/frontend/src/routes/(app)/projects/projects-table.svelte
+++ b/frontend/src/routes/(app)/projects/projects-table.svelte
@@ -6,7 +6,7 @@
import * as DropdownMenu from '#lib/components/ui/dropdown-menu/index.js';
import RowActionsMenu from '#lib/components/arcane-table/row-actions-menu.svelte';
import ContainerActionMenuItem from '#lib/components/arcane-table/cells/container-action-menu-item.svelte';
- import { BoxIcon, EditIcon, StartIcon, RestartIcon, StopIcon, TrashIcon, RedeployIcon } from '#lib/icons/index.js';
+ import { AlertIcon, BoxIcon, EditIcon, StartIcon, RestartIcon, StopIcon, TrashIcon, RedeployIcon } from '#lib/icons/index.js';
import { goto } from '$app/navigation';
import { mode } from 'mode-watcher';
import { toast } from 'svelte-sonner';
@@ -124,7 +124,16 @@
return response.tags;
}
+ function getConfigurationErrorMessage(project: Project): string | undefined {
+ const configurationError = project.configurationError;
+ if (!configurationError) return undefined;
+ const params = { path: configurationError.path, uid: configurationError.uid, gid: configurationError.gid };
+ return configurationError.blocksOperations ? m.env_file_unreadable_blocked(params) : m.env_file_unreadable_ignored(params);
+ }
+
function getStatusTooltip(project: Project): string | undefined {
+ const configurationMessage = getConfigurationErrorMessage(project);
+ if (configurationMessage) return configurationMessage;
return project.status.toLowerCase() === 'unknown' && project.statusReason ? project.statusReason : undefined;
}
@@ -166,6 +175,9 @@
project.status === 'deploying' ||
project.status === 'restarting';
const hasRunningSelection = $derived.by(() => selectedProjects.some((project) => isProjectArchiveBlocked(project)));
+ const hasConfigurationBlockedSelection = $derived.by(() =>
+ selectedProjects.some((project) => project.configurationError?.blocksOperations)
+ );
const columns = $derived.by(
() =>
@@ -213,8 +225,12 @@
action: 'up',
onClick: handleBulkUp,
loading: isBulkLoading.up,
- disabled: !canDeployProject || isAnyLoading || hasArchivedSelection,
- disabledReason: hasArchivedSelection ? m.projects_archived_badge() : undefined,
+ disabled: !canDeployProject || isAnyLoading || hasArchivedSelection || hasConfigurationBlockedSelection,
+ disabledReason: hasConfigurationBlockedSelection
+ ? m.env_file_unreadable_title()
+ : hasArchivedSelection
+ ? m.projects_archived_badge()
+ : undefined,
icon: StartIcon
},
{
@@ -223,8 +239,12 @@
action: 'down',
onClick: handleBulkDown,
loading: isBulkLoading.down,
- disabled: !canDownProject || isAnyLoading || hasArchivedSelection,
- disabledReason: hasArchivedSelection ? m.projects_archived_badge() : undefined,
+ disabled: !canDownProject || isAnyLoading || hasArchivedSelection || hasConfigurationBlockedSelection,
+ disabledReason: hasConfigurationBlockedSelection
+ ? m.env_file_unreadable_title()
+ : hasArchivedSelection
+ ? m.projects_archived_badge()
+ : undefined,
icon: StopIcon
},
{
@@ -233,12 +253,19 @@
action: 'redeploy',
onClick: handleBulkRedeploy,
loading: isBulkLoading.redeploy,
- disabled: !canDeployProject || isAnyLoading || hasRedeployDisabledSelection || hasArchivedSelection,
- disabledReason: hasArchivedSelection
- ? m.projects_archived_badge()
- : hasRedeployDisabledSelection
- ? m.common_redeploy_disabled_arcane_self()
- : undefined,
+ disabled:
+ !canDeployProject ||
+ isAnyLoading ||
+ hasRedeployDisabledSelection ||
+ hasArchivedSelection ||
+ hasConfigurationBlockedSelection,
+ disabledReason: hasConfigurationBlockedSelection
+ ? m.env_file_unreadable_title()
+ : hasArchivedSelection
+ ? m.projects_archived_badge()
+ : hasRedeployDisabledSelection
+ ? m.common_redeploy_disabled_arcane_self()
+ : undefined,
icon: RedeployIcon
},
{
@@ -313,7 +340,12 @@
{#if statusTooltip}
<ArcaneTooltip.Root>
<ArcaneTooltip.Trigger>
- <Badge variant={getStatusVariant(item.status)} minWidth="20">{capitalizeFirstLetter(item.status)}</Badge>
+ <span class="inline-flex items-center gap-1.5">
+ <Badge variant={getStatusVariant(item.status)} minWidth="20">{capitalizeFirstLetter(item.status)}</Badge>
+ {#if item.configurationError}
+ <AlertIcon class="size-4 text-amber-500" aria-label={m.env_file_unreadable_title()} />
+ {/if}
+ </span>
</ArcaneTooltip.Trigger>
<ArcaneTooltip.Content>
<p class="max-w-xs text-xs">{statusTooltip}</p>
@@ -329,7 +361,7 @@
updateInfo={item.updateInfo}
onCheck={() => handleCheckProjectUpdates(item)}
checking={!!checkingProjectIds[item.id]}
- disabled={!!item.isArchived}
+ disabled={!!item.isArchived || !!item.configurationError?.blocksOperations}
class="mr-2"
/>
{/snippet}
@@ -430,8 +462,13 @@
{#snippet RowActions({ item }: { item: Project })}
{@const status = actionStatus[item.id]}
- {@const lifecycleDisabled = item.isArchived || isAnyLoading}
- {@const archivedTitle = item.isArchived ? m.projects_archived_badge() : undefined}
+ {@const configurationBlocked = !!item.configurationError?.blocksOperations}
+ {@const lifecycleDisabled = item.isArchived || isAnyLoading || configurationBlocked}
+ {@const archivedTitle = configurationBlocked
+ ? m.env_file_unreadable_title()
+ : item.isArchived
+ ? m.projects_archived_badge()
+ : undefined}
<RowActionsMenu>
<DropdownMenu.Item onclick={() => goto(`/projects/${item.id}`)} disabled={isAnyLoading}>
<EditIcon class="size-4" />
diff --git a/types/project/project.go b/types/project/project.go
index d6e07fc4f..5390af89e 100644
--- a/types/project/project.go
+++ b/types/project/project.go
@@ -399,6 +399,35 @@ type CreateReponse struct {
Tags []Tag `json:"tags"`
}
+// ConfigurationError describes a filesystem-level configuration problem that
+// prevents Arcane from fully using a project.
+type ConfigurationError struct {
+ // Code identifies the configuration problem.
+ //
+ // Required: true
+ Code string `json:"code"`
+
+ // Path is the offending file path.
+ //
+ // Required: true
+ Path string `json:"path"`
+
+ // UID is the effective user id of the Arcane runtime.
+ //
+ // Required: true
+ UID int `json:"uid"`
+
+ // GID is the effective group id of the Arcane runtime.
+ //
+ // Required: true
+ GID int `json:"gid"`
+
+ // BlocksOperations indicates whether the problem prevents project operations.
+ //
+ // Required: true
+ BlocksOperations bool `json:"blocksOperations"`
+}
+
// Details contains detailed information about a project.
type Details struct {
// Tags are the effective UI and Compose tags for the project.
@@ -570,6 +599,11 @@ type Details struct {
//
// Required: false
RedeployDisabled bool `json:"redeployDisabled,omitempty"`
+
+ // ConfigurationError reports a filesystem-level configuration problem detected for this project.
+ //
+ // Required: false
+ ConfigurationError *ConfigurationError `json:"configurationError,omitempty"`
}
// Destroy is used to destroy a project.