archiver v8 changed its CJS export from a function to an object of class
constructors ({ Archiver, ZipArchive, TarArchive, JsonArchive }). The route
still called archiver('zip', opts), which throws `TypeError: archiver is not
a function` — a deterministic throw in the main flow, returning 500.
This was masked until the prior membership fix: before it, the empty
assetToGrantedAlbum map made the route 404 at "No valid assets found"
*before* reaching the archiver line. Once the map populated and downloads
were authorized, execution reached archiver('zip') and threw.
Fixed: `new archiver.ZipArchive({ zlib: { level: 0 } })` — same
pipe/append/finalize/abort interface. Verified the full round-trip
(append → finalize → Readable.toWeb → drain) produces a valid PK zip.
Also surface the server error code in DownloadLightboxForm so future
failures show the real code (status + {code}) in the browser console and
alert instead of a generic "Download fehlgeschlagen".
Co-Authored-By: Claude <noreply@anthropic.com>
The bulk-download handler still returned 500 after the membership fix.
Three issues:
1. Repeat downloads were broken: the handler passed priorUsages[0].id
(the usage id) straight as downloadId, but claimAuthorized looks up
download_events.id (the intent id) — so repeat assets never matched
and were silently skipped. Now calls createRepeatDownload to mint a
proper repeat intent, matching the single-download flow.
2. The catch block returned a generic 500 for every error, hiding the
cause (the user only saw "Download fehlgeschlagen"). Added
mappedBulkError so UsageAccountingError surfaces as its real code
(503 IMMICH_UNAVAILABLE, 404 ASSET_NOT_IN_ALBUM, …) and the server
log keeps the full stack.
3. The assetId→album map was built by fetching up to 1000 assets per
granted album WITH withExif, then createNewUsage re-fetched per
asset — heavy enough to time Immich out under load. The map only
needs ids, so it now passes withExif:false (searchPhotos gained a
withExif option, default true to preserve the gallery's orientation
filter and masonry aspect ratios).
Co-Authored-By: Claude <noreply@anthropic.com>
getAlbum no longer returns assets on current Immich (AlbumService.get uses
{ withAssets: false }), so the old "getAlbum + iterate album.assets" best
practice is wrong and caused the download-404 bug. Document the
search/metadata id+albumIds membership check now in use.
Co-Authored-By: Claude <noreply@anthropic.com>
The previous getAlbum fix (removing ?withoutAssets=true) was insufficient:
current Immich's GET /albums/:id NEVER returns assets — AlbumService.get
calls findOrFail with { withAssets: false } and the withoutAssets param is
gone. So album.assets was always empty and every download still failed with
ASSET_NOT_IN_ALBUM → 404. The AI_MEMORY "getAlbum + iterate album.assets"
guidance was stale (written for an older Immich API).
Membership is now verified via /search/metadata with an id + albumIds filter,
which returns the asset only if it belongs to the album. This is the
authoritative test (asset.albums is unreliable for older assets too).
- usages/service.ts: loadRequestedAlbum checks isAssetInAlbum via searchPhotos
before fetching the album name; getAlbum now only provides albumName.
- bulk-download/route.ts: build the assetId→album map via searchPhotos per
granted album instead of the empty getAlbum().assets iteration.
- immich client/types: add optional `id` to the searchPhotos input.
- tests: usages mocks now stub searchPhotos; the 13 pre-existing service
test failures (mock returned getAlbum without assets → TypeError) are
resolved — 20/20 pass.
Co-Authored-By: Claude <noreply@anthropic.com>
Three production bugs on redaktionen.leon-tonhaeuser.de:
1. Download 404 (POST /api/download-intents → 404). getAlbum requested
?withoutAssets=true, so album.assets was always empty and the usages
membership check (album.assets.some(id)) always failed → ASSET_NOT_IN_ALBUM
→ 404. Same root cause broke bulk-download's assetToGrantedAlbum map.
Removed withoutAssets so consumers that authorize via album.assets get the
real list; grants/thumbnail consumers ignore the extra data.
2. _next/image 400 on thumbnail proxy. next/image's optimizer choked on the
watermarked streaming thumbnail response. Thumbnails are already
server-resized to 800px, so the optimizer added nothing — switched
leuchtkasten + admin AlbumGrid to plain <img>, matching photo-gallery.
3. Cross-album search "finds nothing". Immich albumIds is AND across albums
(PR #18985): one /search/metadata call with all granted ids requires the
asset to be in EVERY album, so single-album photos never match. Album-
internal search passed one id so it worked. Fan out per granted album and
merge; callers already paginate in-app.
Also drop the jahr filter from the album-internal search form (unnecessary
within a single album); backend still honors a jahr query param.
Co-Authored-By: Claude <noreply@anthropic.com>
The root layout already renders <LegalFooter/> (Impressum, Datenschutz,
Nutzungsbedingungen) on every page. The login page defined its own local
LegalFooter with the same three links, and the registration form carried a
standalone Impressum link — so Impressum (and on login, all three) appeared
twice. Drop the redundant per-page copies; the global footer covers them.
Co-Authored-By: Claude <noreply@anthropic.com>
Album overview:
- AlbumContactSheet now uses cover tiles in the photo-gallery aesthetic:
object-fit: cover, 4/3 tiles, persistent bottom gradient with album name
+ photo count, hover zoom. Drops the old 3:2 contain tiles + monospace
caption strip.
Diagnostics (download + merkzettel both failed silently for the user):
- UsageDialog now reads the server's { code } from /api/download-intents and
maps each stable error code (FORBIDDEN, NOT_FOUND, UPSTREAM_UNAVAILABLE,
ACCOUNTING_UNAVAILABLE, ...) to a specific German message instead of the
generic "try again". The fallback includes the raw code so unmapped
failures stay actionable when reported back.
- LightboxToggleButton logs the caught server-action error to the console
(and notes the dev terminal) instead of reverting the optimistic toggle
with no signal. Root cause still needs the live error; this makes it
visible.
Co-Authored-By: Claude <noreply@anthropic.com>
The album search could not distinguish portrait from landscape: the format
filter ran client-side over a single 60-item page and relied on exifInfo that
Immich never returned (no withExif flag), so the orientation guard fell
through and every photo matched every filter. Pagination links also dropped
format/jahr on the next page.
- immich/client: send withExif: true on /search/metadata so
exifImageWidth/Height are populated for orientation filtering and masonry
aspect ratios.
- albums/filter (new): filter + paginate across the full fetched set so total,
page slice and has-more-pages stay consistent with active filters; both the
album detail and the cross-album search pages use it.
- albums/photo-gallery (new client component): masonry grid with native
EXIF aspect ratios (object-fit: cover, no more 3:2 letterboxing), hover
overlay with filename/date + merken/lizenzieren/vergrößern, and a
full-screen lightbox with keyboard nav (Esc/arrow keys).
- catalog-content: drop the old PhotoContactSheet; keep AlbumContactSheet and
thread format/jahr through PhotoPagination links.
- Album detail search form restyled to the editorial design system (sharp ink
borders) instead of the shadcn rounded card.
- Tests: filter.test.ts covers the orientation/year/pagination logic;
catalog-content.test.tsx updated to the gallery + lightbox structure;
immich client test expects withExif: true.
Skipped: global search form still uses shadcn styling (visually inconsistent
but functionally fixed); albums > 1000 photos lose tail items (noted with a
ponytail ceiling comment).
Co-Authored-By: Claude <noreply@anthropic.com>
Immich v3 (server runs v3.1.0) returns search `nextPage` as an opaque cursor
string instead of a page number. The client schema validated `nextPage` as
`number`, so every album open failed schema validation and surfaced as
"Fotos momentan nicht erreichbar" (the catalog catch swallows the real
IMMICH_INVALID_RESPONSE into IMMICH_UNAVAILABLE).
Accept `string | number` for nextPage/previousPage in the schema and the
ImmichSearchPage type; we only use nextPage as a has-more-pages signal.
Pagination links are now derived from the current page number (currentPage ± 1)
instead of the returned nextPage value, since the v3 cursor can't be used as a
page number. Album page passes the normalized current page through.
Add a client test locking the v3 cursor-string response.
Co-Authored-By: Claude <noreply@anthropic.com>
Album assignment 500'd with IMMICH_UNAVAILABLE because grantAlbum verified the
album via getAlbum, which pulled the full album incl. all assets — large albums
blew the 15s timeout. Request ?withoutAssets=true so Immich returns metadata
only (no consumer reads .assets); make assets optional in the schema.
Album thumbnails 500'd because next/image rejected the ?albumId= query string
(images.localPatterns). Switch the album page to a plain <img>, matching the
editorial catalog (next/image was used in exactly one place).
Overhaul action error handling: grantAlbumAction/revokeAlbumAction/approveEditorialAction
returned a thrown Error, which Next.js turns into an opaque error-digest page —
the German message never reached the admin. They now return {ok,message}; new
client AlbumGrantForm + ApproveForm use useActionState to show the message
inline. Auth (requireAdmin) still throws (guarded by the layout). Update both
action test files to the result contract.
Co-Authored-By: Claude <noreply@anthropic.com>
Admin used an undefined `.portal-shell` class plus the landing-page `.masthead`
markup, so the layout had no background/min-height and CSS "kackte rein".
Generalize PortalShell to take brand/nav props, switch admin/layout.tsx to it
(dark portal masthead + BrandLogo + admin nav), and pass the editorial nav from
redaktion/layout.tsx so both surfaces share one shell.
Add a LogoutButton client component (Better Auth signOut → hard navigate to
/anmelden) rendered into the masthead.
Style the admin content that had no rules: `.content-section dl/dt/dd` mirrors
`.editorial-section dl` (admin detail page), `.editorial-list` mirrors
`.billing-editorial-list` (Redaktionen index, replacing browser bullets),
`.portal-signout` for the dark masthead. Mobile: meta wraps, dl goes single
column.
Update logo.test.tsx to PortalShell's new required props.
Co-Authored-By: Claude <noreply@anthropic.com>
Better Auth's parseUserOutput filters the session user to declared fields
only (filterOutputFields over getFields(options,'user','output')). The drizzle
adapter selects the custom `role` column, but because it was never declared in
the Better Auth config, parseUserOutput stripped it — session.user.role was
always undefined. That broke two things: the root redirect fell through to
/redaktion/alben for admins (role !== 'ADMIN'), and requireAdmin threw
ADMIN_REQUIRED on every /admin page (role !== 'ADMIN').
Declare role via user.additionalFields (the documented custom-field API; the
`fields` map only renames core columns). input:false keeps it unsettable on
signUp — the DB default and the admin seed own it — and defaultValue matches
the column default so inserts never send null into the NOT NULL portalRole enum.
Co-Authored-By: Claude <noreply@anthropic.com>
LoginForm mapped every signIn failure to one generic sentence. Better Auth
returns distinct codes in signIn order — password check, then
requireEmailVerification (EMAIL_NOT_VERIFIED), then the session.create.before
hook canCreateSession (FAILED_TO_CREATE_SESSION). Map those to specific
messages: unverified email, not-yet-approved account, invalid credentials.
canCreateSession returns true only for ADMIN or editorial status 'active', and
onEmailVerified → markPendingApproval leaves verified editorials at
pending_approval until an admin approves — so the not-approved message is the
common post-verification login block.
Co-Authored-By: Claude <noreply@anthropic.com>
/admin had no index page (only /admin/redaktionen, /abrechnungen, /audit),
so authenticated admins hitting /admin — including the admin layout's
wordmark link — got a 404. Add src/app/admin/page.tsx that redirects to
/admin/redaktionen, and point the root home redirect at the same path so
post-login doesn't 404.
Co-Authored-By: Claude <noreply@anthropic.com>
The root page was a static public landing that always shows a
'Zum Portal' button pointing at /anmelden, and /anmelden never
redirects authenticated users. After login the callbackURL '/' landed
on this static page, so the user saw the login form again — the
post-login loop. Make / an async server component that reads the
session and redirects to /admin (admin) or /redaktion/alben (editorial);
unauthenticated users still see the landing.
Co-Authored-By: Claude <noreply@anthropic.com>