app:url:download crashes with MissingIdentifierField after the download process stops

Open Beginner friendly
#54 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
69/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
php
Domain
backend, cli

Research direction

Start with ProcessStoppedListener.php, especially onCliProcessStopEvent() and the find($event->downloadJob->getId()) call described in the issue. Trace how UrlDownloadCommand creates its DownloadJob and check existing listener tests. Verify that running the command exits successfully and that a test covers an unpersisted job.

Written by the indexing model from the issue text.

Description

bug good first issue

Problem

bin/console app:url:download <url> crashes after the first yt-dlp run. Found while testing #46 / #52:

[Doctrine\ORM\Exception\MissingIdentifierField]
The identifier id is missing for a query of App\Entity\DownloadJob

  at ProcessStoppedListener.php:38  ($this->downloadJobRepository->find($event->downloadJob->getId()))
  ... AbstractCliDownloader->runDownloadProcess()
  ... UrlDownloadCommand->execute()

UrlDownloadCommand creates a DownloadJob that is never persisted (id is null). ProcessStoppedListener::onCliProcessStopEvent() calls find(null) on it, which throws. The download itself happens, but the command exits with an error, and since #52 the retry without the download archive never runs from this command.

Proposed fix

Either:

  • Guard the listener: skip the database work in ProcessStoppedListener when the job has no id (null === $event->downloadJob->getId()). The command stays a "download only, don't record" tool.
  • Persist the job in the command: save the job (with downloader and state) before downloading, so CLI downloads behave like API downloads and get events and linked files.

The guard is the smaller fix. Persisting may be preferable if CLI downloads should show up in the admin panel.

Verification

bin/console app:url:download --downloader yt-dlp-cli <url> exits with 0, and a test covering the listener with an unpersisted job.

Dominant language
PHP
Stars
1
Forks
0
Avg merge
3d 50m
Merged PRs (30d)
9

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from FetchDock/fetchdock-server

All issues in FetchDock/fetchdock-server

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.