BUG: Sharing an album with a very large expiry returns 500 and leaves the share server listening

オープン
#1,798 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 3 日以内に返信

@swastiksharma45 がすでに取り組んでいます。

2026年11月30日 から。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
34/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
fastapi, python
領域
api, backend

調査の方向性

Read backend/app/schemas/share.py for the expires_in_minutes validation and backend/app/utils/share.py for the order of server startup and registry creation. Start with the share API tests and add coverage for an expiry above the chosen maximum. Done means oversized values return a 422 response without starting the listener; the issue names no test file, so locate the relevant tests in the repository.

索引モデルが issue の本文から書いたものです。

説明

bug
Is there an existing issue for this?
  • I have searched the existing issues
What happened?

Description

POST /share/albums/{album_id} accepts any positive expires_in_minutes. If the value is large enough to push the expiry past year 9999, share_registry_create raises OverflowError: date value out of range. The route only catches OSError, so the client gets a plain-text 500 Internal Server Error.

Worse, share_util_create starts the LAN share server before creating the registry entry, so when this is the first share the listener stays up on the network with zero active shares.

(Note: Checked existing issues including #1635 — #1635 handled the leftover listener on share expiration, whereas this issue is specifically about expires_in_minutes overflowing datetime with OverflowError during creation.)

Steps to reproduce

  1. Create any album.
  2. POST /share/albums/<album_id> with body {"expires_in_minutes": 5000000000}.
  3. Response is 500 Internal Server Error (plain text, not the usual ErrorResponse JSON).
  4. GET /share/ lists no shares, but the share server is still listening on port 52125.

For comparison, {"expires_in_minutes": 60} returns 200, starts the listener on port 52125 with 1 active share, and revoking it stops the listener (listener running: False). The cut-off is roughly 4.19 billion minutes.

Expected behavior

The request is rejected with a 422 validation error, and the share server is not started.

Cause

  • backend/app/schemas/share.py:14: expires_in_minutes has gt=0 but no upper bound.
  • backend/app/share/registry.py:82: _now() + timedelta(minutes=...) overflows.
  • backend/app/utils/share.py:92-93: share_server_start() runs before share_registry_create().
  • backend/app/routes/share.py:106: only OSError is handled.

Suggested fix

Add an upper bound to expires_in_minutes (e.g., le= a sane maximum such as 1 year / 525600 minutes) so Pydantic/FastAPI validation rejects oversized values with 422 before the server starts, and add a unit test for oversized expiry values.

The UI only offers fixed expiry presets, so this is reachable through the API rather than the share dialog.

I'd like to work on this if it's approved.

Record
  • I agree to follow this project's Code of Conduct
主要言語
Python
スター
322
フォーク
793
平均マージ
6日 10時間
マージ済み PR(30日)
20

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

AOSSIE-Org/PictoPy のほかの issue

AOSSIE-Org/PictoPy の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。