Skip to content

Some assets do not have any metadata and trigger an exception #526

@nsabosch

Description

@nsabosch

Bug description

Assets without metadata trigger an exception and prevent the Control Panel from listing assets in the affected directory.

Exception Details

  • Class: TypeError
  • Message: Carbon\Carbon::createFromTimestamp(): Argument statamic/cms#1 ($timestamp) must be of type string|int|float, null given, called in .../vendor/statamic/cms/src/Assets/Asset.php on line 598
  • Code: 0
  • Handled: false
  • File: vendor/nesbot/carbon/src/Carbon/Traits/Timestamp.php:29

Stack Trace (most recent call first)

  • [0] Carbon\Carbon::createFromTimestamp()
    at vendor/nesbot/carbon/src/Carbon/Traits/Timestamp.php:29
  • [1] Carbon\Carbon::createFromTimestamp()
    at vendor/statamic/cms/src/Assets/Asset.php:598
  • [2] Statamic\Assets\Asset->lastModified()
    at vendor/laravel/framework/src/Illuminate/Support/Traits/ForwardsCalls.php:23
  • [3] Illuminate\Http\Resources\Json\JsonResource->forwardCallTo()
    at vendor/laravel/framework/src/Illuminate/Http/Resources/DelegatesToResource.php:155
  • [4] Illuminate\Http\Resources\Json\JsonResource->__call()
    at vendor/statamic/cms/src/Http/Resources/CP/Assets/FolderAsset.php:19
  • [5] Statamic\Http\Resources\CP\Assets\FolderAsset->toArray()
    at vendor/laravel/framework/src/Illuminate/Collections/HigherOrderCollectionProxy.php:66
  • [6] Illuminate\Support\HigherOrderCollectionProxy->Illuminate\Support{closure}()
    at [internal function]
    ...

How to reproduce

  1. Configure Statamic to use the Eloquent assets metadata driver.
  2. Ensure an asset exists where the metadata is present but does not include anything:
{
  "data": []
}
  1. Open the Control Panel and navigate to the asset container / folder that includes this asset.

  2. The Control Panel fails to list the assets and throws the exception (createFromTimestamp(null)).

Temporary hotfix / workaround

Manually setting a last_modified timestamp in the metadata prevents the exception, e.g.:

{
  "data": [],
  "last_modified": 1711738717
}

We haven’t identified the root cause yet. In our case, assets with missing metadata appear intermittently across multiple file types (e.g. .mp4, .jpg, .png).

Logs

Environment

Environment

Laravel Version: 12.41.1
PHP Version: 8.3.27
Composer Version: -
Environment: production
Debug Mode: OFF
Maintenance Mode: OFF
Timezone: UTC
Locale: en

Cache

Config: CACHED
Events: CACHED
Routes: CACHED
Views: CACHED

Drivers

Broadcasting: log
Cache: redis
Database: mysql
Logs: stack / single, flare, nightwatch
Mail: ses
Queue: database
Scout: database
Session: redis

Storage

public/storage: NOT LINKED
disk: s3

Statamic

Addons: 4
Sites: 27
Stache Watcher: Disabled
Static Caching: Disabled
Version: 5.70.0 PRO

Statamic Addons

statamic/eloquent-driver: 4.35.1

Statamic Eloquent Driver

Asset Containers: eloquent
Assets: eloquent
Blueprints: file
Collection Trees: eloquent
Collections: file
Entries: eloquent
Fieldsets: file
Form Submissions: file
Forms: eloquent
Global Sets: eloquent
Global Variables: eloquent
Navigation Trees: eloquent
Navigations: file
Revisions: eloquent
Sites: file
Taxonomies: file
Terms: eloquent
Tokens: eloquent

Installation

Existing Laravel app

Additional details

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    assetsbugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions