Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

sirvantos's avatar

Typed property must be unknown or null Error (Project powered by Vapor)

Hello guys.

I have a pretty simple Laravel api project hosted on AWS Lambda (Vapor). it works fine on php 7.3 but as soon as i switched to php 7.4 (+ update some vendor libs like Response Cache) i started to get a very strange error

Typed property Spatie\ResponseCache\ResponseCacheRepository::$cache must be unknown or null, Illuminate\Cache\Repository used

"file": "/var/task/vendor/spatie/laravel-responsecache/src/ResponseCacheRepository.php:17",

code below:

https://github.com/spatie/laravel-responsecache/blob/6.4.0/src/ResponseCacheRepository.php

Bug behaviour is a very strange. As soon as i deployed code it works fine for 5 - 10 mins, next i start to get small amount of bug reports (see error details above), and amount of reports growing exponentially.

it works fine on staging AWS Lambda.

My production server has approximatelly loading about 10 req / s

Can't find any description for like errors :(

Did you see similar errors in your projects ?

Thanks

0 likes
10 replies
bugsysha's avatar

Looks like you are the first. Maybe you should create an issue on GitHub for that repository/package. Freek probably knows it best and how to fix it. Until then go back to 7.3.

sirvantos's avatar

@bugsysha Not sure that it will help because my unit tests are passed (include tests for cache), so code is correct, issue happens only on Vapor Prod :(

bugsysha's avatar

I know that Taylor showcased a feature where you can run all of your tests on Vapor where you have matching environment. So why don't you run tests on Vapor with vapor test to see if they will pass?

sirvantos's avatar

@bugsysha another thing i can't google explanation of error

Typed property Spatie\ResponseCache\ResponseCacheRepository::$cache must be unknown or null, Illuminate\Cache\Repository used

Error is a very strange itself.......

bugsysha's avatar

I did it :) they are passed

Then tests are not covering that issue. Hm...

sirvantos's avatar

Not so simple :) They are covered for sure :(

  • code works on staging (can't repeat it)
  • code works on prod for 5 - 10 mins (possible because lambda container respawn delay)
bugsysha's avatar

Maybe you are just not testing it on your staging at a rate at which your production is being hit.

Please or to participate in this conversation.