beyondcode / invoker-community

74 stars 2 forks source link

[Bug]: Undefined array key "timestamp" when I click anything in the app #306

Closed Ahrengot closed 1 year ago

Ahrengot commented 2 years ago

Operating system

macOS Big Sur 11.5.2

Laravel Version

v9.19

PHP Version

PHP 8.1.0 (cli) (built: Nov 28 2021 02:36:02) (NTS)

Project Location

Local

Bug description

I'm getting this error on one of my projects and it's breaking every feature in the app. I have other projects that work just fine.

The error seems to be about a casting error for a timestamp column. I tried commenting out all model casts but that didn't fix the issue. I also looked through all tables in the database, and none of them have a timestamp column.

I can provide a database dump and the source code for my project if needed.

Steps to reproduce

Relevant log output

ErrorException 

  Undefined array key "timestamp"

  at phar:/Applications/Invoker.app/Contents/Resources/invoker.phar/src/Factories/AttributeItem.php:51
     47▕         if (isset($model->getCasts()[$column->getName()])) {
     48▕             $cast = \Illuminate\Support\Arr::first(\explode(':', $model->getCasts()[$column->getName()]));
     49▕             return self::MODEL_CAST_TYPES[$cast] ?? $cast;
     50▕         }
  ➜  51▕         return self::CAST_TYPES[$column->getType()->getName()];
     52▕     }
     53▕     public static function getTitle(string $name) : string
     54▕     {
     55▕         return \ucwords(\str_replace('_', ' ', $name));

  1   phar:/Applications/Invoker.app/Contents/Resources/invoker.phar/src/Factories/AttributeItem.php:51
      Illuminate\Foundation\Bootstrap\HandleExceptions::Illuminate\Foundation\Bootstrap\{closure}("Undefined array key "timestamp"", "phar:///Applications/Invoker.app/Contents/Resources/invoker.phar/src/Factories/AttributeItem.php")

  2   phar:/Applications/Invoker.app/Contents/Resources/invoker.phar/src/Factories/AttributeItem.php:25
      _HumbugBoxf4b902e0e9ad\Invoker\Factories\AttributeItem::getCastFromColumn(Object(App\Models\Application), Object(Doctrine\DBAL\Schema\Column))
ralphjsmit commented 2 years ago

I also experience this error. Would be great if this could be fixed ASAP.

mpociot commented 1 year ago

We added a fallback for this error, even though we were unable to reproduce this properly – this will be available within the next version of Invoker.

If you could still share more information about the model/database/migration that produces this, that would be great.