agregarr / agregarr/agregarr

Collections with exclamation mark - broken image in saved posters

未關閉
#585 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
awaiting-triage bug
主要語言
TypeScript
星號
1k
分支
41
PR 合併指標
30 天內沒有已合併 PR

描述

### Description

Collection names containing an exclamation mark (`!`) can result in broken images under:

`Posters -> Collection Posters -> Saved Posters`

In my case the collection names came from Maintainerr 3.7.0 and included `!`:

- `Movies leaving stuartmedia Soon!`
- `Shows Leaving Soon!`

Agregarr generated/saved poster files using filenames derived from those collection names:

```text
Movies_leaving_stuartmedia_Soon!_(Movies).jpg
Shows_Leaving_Soon!_(TV_Shows).jpg
````

The files existed on disk and were readable inside the container, but the UI showed broken images and Agregarr logged `Poster file not found`.

This appears to be caused by a mismatch in filename handling:

* `sanitizeFilename()` allows `!` to remain in generated filenames.
* `isValidFilename()` later rejects filenames containing `!`.
* `posterExists()` then returns `false`.
* The UI route reports `Poster file not found`, even though the file exists.

So this is not a filesystem, Docker, mount, or permission issue. It appears to be Agregarr creating/storing a filename that its own poster-serving validation later rejects.

## Expected Behavior

Agregarr should either:

* sanitize `!` out of generated poster filenames before saving them, or
* allow `!` consistently in `isValidFilename()` if that character is intended to be supported.

The app should not create/store poster filenames that it later refuses to serve.

## Actual Behavior

Agregarr stores/references poster filenames containing `!`, but later fails to serve them.

Example log:

```text
Failed to load poster file: Poster file not found: Shows_Leaving_Soon!_(TV_Shows).jpg
Poster file not found or failed to load {"filename":"Shows_Leaving_Soon!_(TV_Shows).jpg","error":"Failed to load poster file"}

Failed to load poster file: Poster file not found: Movies_leaving_stuartmedia_Soon!_(Movies).jpg
Poster file not found or failed to load {"filename":"Movies_leaving_stuartmedia_Soon!_(Movies).jpg","error":"Failed to load poster file"}
```

But the files existed inside the container:

```text
/app/config/posters/Movies_leaving_stuartmedia_Soon!_(Movies).jpg
/app/config/posters/Shows_Leaving_Soon!_(TV_Shows).jpg
```

Container-side validation:

```text
uid=1000(node) gid=10000 groups=10000

/app/config/posters:
-rw-r--r-- 1 node 10000 210.7K Movies_leaving_stuartmedia_Soon!_(Movies).jpg
-rw-r--r-- 1 node 10000 185.4K Shows_Leaving_Soon!_(TV_Shows).jpg

shows poster visible
movies poster visible
```

The references also existed in `settings.json`:

```text
"customPoster": "Movies_leaving_stuartmedia_Soon!_(Movies).jpg"
"customPoster": "Shows_Leaving_Soon!_(TV_Shows).jpg"
```

### Version

2.4.2

### Steps to Reproduce

1. Have Maintainerr create or manage a collection with `!` in the collection name.

* Example: `Shows Leaving Soon!`
* Example: `Movies leaving stuartmedia Soon!`
2. In Agregarr, run/sync the Plex collections so the renamed/managed collections are discovered.
3. Run poster-related jobs / poster overlay application.
4. Go to:

* `Posters -> Collection Posters -> Saved Posters`
5. Observe broken poster images.
6. Check Agregarr logs.

I do not know if this only occurs with Maintainerr-created collections, but based on the source code it looks like any flow that produces a poster filename containing `!` could trigger the same problem.

### List Links

_No response_

### Screenshots

I do not have screenshots available, but the visible symptom was broken images under:

`Posters -> Collection Posters -> Saved Posters`

### Logs

```shell
2026-04-25T16:38:19.478Z [error]: Failed to load poster file: Poster file not found: Shows_Leaving_Soon!_(TV_Shows).jpg {"stack":"Error: Poster file not found: Shows_Leaving_Soon!_(TV_Shows).jpg\n at loadPosterFile (/app/dist/lib/posterFileManager.js:76:19)\n at /app/dist/routes/posters.js:827:79"}

2026-04-25T16:38:19.479Z [debug]: Poster file not found or failed to load {"filename":"Shows_Leaving_Soon!_(TV_Shows).jpg","error":"Failed to load poster file"}

2026-04-25T16:38:19.481Z [error]: Failed to load poster file: Poster file not found: Movies_leaving_stuartmedia_Soon!_(Movies).jpg {"stack":"Error: Poster file not found: Movies_leaving_stuartmedia_Soon!_(Movies).jpg\n at loadPosterFile (/app/dist/lib/posterFileManager.js:76:19)\n at /app/dist/routes/posters.js:827:79"}

2026-04-25T16:38:19.481Z [debug]: Poster file not found or failed to load {"filename":"Movies_leaving_stuartmedia_Soon!_(Movies).jpg","error":"Failed to load poster file"}

Earlier related log entries:

2026-04-25T06:00:27.725Z [info][Poster Discovery]: Poster URL changed, deleting old file {"collectionTitle":"Movies leaving stuartmedia Soon!","oldPath":"Movies_leaving_stuartmedia_Soon!_(Movies).jpg"}

2026-04-25T06:00:27.734Z [info][Poster Discovery]: Poster URL changed, deleting old file {"collectionTitle":"Shows Leaving Soon!","oldPath":"Shows_Leaving_Soon!_(TV_Shows).jpg"}
```

### Additional Context

I worked around the issue by:

1. Removing `!` from the Maintainerr rule/collection name.
2. Running Maintainerr rules and allowing processing to complete.
3. Confirming the new collection name in Maintainerr.
4. Clicking `Handle collections` in Maintainerr and allowing that to complete.
5. Confirming the collections were renamed in Plex.
6. Running Agregarr `Plex collections sync`.
7. Confirming the rename under Agregarr `All Collections`.
8. Running poster overlay jobs.
9. Manually deleting the old `!` poster files from `/app/config/posters`.
10. Making a change to the default Agregarr poster template to force fresh poster generation.

After that, the errors stopped and Plex showed the updated collection posters.

貢獻指南

這個儲存庫沒有索引到貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。