firefly-iii/firefly-iii · error · FireflyException
300006
300006
Error message
300006: Journal #%d, transaction #%d has no destination account.
What it means
Thrown by correction:transaction-types when the destination transaction row exists but its ->account relation resolves to null. This means transactions.account_id points to a row that no longer exists in the accounts table (dangling foreign key), so code 300006 is raised. Firefly III relies on the relation being non-null to infer journal types.
Source
Thrown at app/Console/Commands/Correction/CorrectsTransactionTypes.php:136
* @throws FireflyException
*/
private function getDestinationAccount(TransactionJournal $journal): Account
{
$collection = $journal->transactions->filter(static fn (Transaction $transaction): bool => $transaction->amount > 0);
if (0 === $collection->count()) {
throw new FireflyException(sprintf('300004: Journal #%d has no destination transaction.', $journal->id));
}
if (1 !== $collection->count()) {
throw new FireflyException(sprintf('300005: Journal #%d has multiple destination transactions.', $journal->id));
}
/** @var Transaction $transaction */
$transaction = $collection->first();
/** @var null|Account $account */
$account = $transaction->account;
if (null === $account) {
throw new FireflyException(sprintf('300006: Journal #%d, transaction #%d has no destination account.', $journal->id, $transaction->id));
}
return $account;
}
/**
* @throws FireflyException
*/
private function getSourceAccount(TransactionJournal $journal): Account
{
$collection = $journal->transactions->filter(static fn (Transaction $transaction): bool => $transaction->amount < 0);
if (0 === $collection->count()) {
throw new FireflyException(sprintf('300001: Journal #%d has no source transaction.', $journal->id));
}
if (1 !== $collection->count()) {
throw new FireflyException(sprintf('300002: Journal #%d has multiple source transactions.', $journal->id));
}
View on GitHub (pinned to fd8791d08d)
Solutions
- Find dangling references: SELECT t.id, t.account_id FROM transactions t LEFT JOIN accounts a ON a.id = t.account_id WHERE a.id IS NULL.
- Back up, then either re-point each transaction to a valid account_id or delete the orphaned transaction rows (correction:orphaned-transactions does the latter).
- Verify foreign key constraints exist and are enforced on your database engine (InnoDB, not MyISAM; PRAGMA foreign_keys for SQLite).
- Re-run the correction command to confirm a clean pass.
Example fix
php artisan correction:orphaned-transactions # removes transaction rows whose account no longer exists
Defensive patterns
Strategy: try-catch
Validate before calling
-- pre-flight: transactions pointing at missing accounts SELECT t.id FROM transactions t LEFT JOIN accounts a ON a.id = t.account_id WHERE a.id IS NULL;
Try / catch
try {
$this->artisan('correction:transaction-types');
} catch (FireflyException $e) {
if (preg_match('/300006: Journal #(\d+), transaction #(\d+)/', $e->getMessage(), $m)) {
// re-point transaction (int)$m[2] to a valid account_id or remove it, re-run
}
} Prevention
- Never truncate or prune the accounts table by hand.
- Use InnoDB (or enforce FKs) so account deletion cascades or fails loudly.
- Run correction:orphaned-transactions periodically as routine hygiene.
When it happens
Trigger: Running firefly-iii:correct-database or correction:transaction-types where a transaction row references a deleted or never-created account. Typical after account deletion without cascade, partial restores, or direct SQL truncation of accounts.
Common situations: Databases where accounts were deleted with foreign key checks disabled, or where the accounts table was partially restored. Imports that wrote account_id values computed against a different database. Schema drift after switching between MySQL/PostgreSQL/SQLite copies.
Related errors
AI-assisted analysis of firefly-iii/firefly-iii@fd8791d08d (2026-08-17).
Data as JSON: /api/errors/4557260cb17fb05a.
Report an issue: GitHub.