Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating Gifts Fails, Contrary to UI Message #5397

Closed
mohammed90 opened this issue Jul 31, 2021 · 5 comments · Fixed by #5547
Closed

Creating Gifts Fails, Contrary to UI Message #5397

mohammed90 opened this issue Jul 31, 2021 · 5 comments · Fixed by #5547

Comments

@mohammed90
Copy link

mohammed90 commented Jul 31, 2021

Describe the bug

When trying to add a gift, the UI gives success message but nothing is reflected. No gift entries can be created at all. Including an image results in the logs provided below. The attached photos are stored correctly and displayed in the Photos tab. The UI responds with success no matter what.

Screenshots

N/A

Which version are you using:

  • A server you maintain yourself (if so, please indicate your current version of Monica): v3.0.1

Additional context

I'm holding back the upgrade until the issue of search performance is resolved. Skimming the changes in the versions between v3.0.1 and latest, I don't see anything explicitly related to creating new gift entry. If the maintainers find relevance, I'll gladly upgrade.

Error log:

 monicahq_1  | [2021-07-31 01:59:46] prodcution.ERROR: Attempt to read property "id" on null {"userId":1,"exception":"[object] (ErrorException(code: 0): Attempt to read property \"id\" on null at /var/www/html/vendor/laravel/framework/src/Illuminate/Http/Resources/DelegatesToResource.php:136)
 monicahq_1  | [stacktrace]
 monicahq_1  | #0 /var/www/html/vendor/laravel/framework/src/Illuminate/Http/Resources/DelegatesToResource.php(136): Illuminate\\Foundation\\Bootstrap\\HandleExceptions->handleError()
 monicahq_1  | #1 /var/www/html/app/Http/Resources/Gift/Gift.php(24): Illuminate\\Http\\Resources\\Json\\JsonResource->__get()
 monicahq_1  | #2 /var/www/html/vendor/laravel/framework/src/Illuminate/Http/Resources/Json/JsonResource.php(95): App\\Http\\Resources\\Gift\\Gift->toArray()
 monicahq_1  | #3 /var/www/html/vendor/laravel/framework/src/Illuminate/Http/Resources/Json/ResourceResponse.php(39): Illuminate\\Http\\Resources\\Json\\JsonResource->resolve()
 monicahq_1  | #4 /var/www/html/vendor/laravel/framework/src/Illuminate/Http/Resources/Json/JsonResource.php(221): Illuminate\\Http\\Resources\\Json\\ResourceResponse->toResponse()
 monicahq_1  | #5 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(774): Illuminate\\Http\\Resources\\Json\\JsonResource->toResponse()
 monicahq_1  | #6 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(761): Illuminate\\Routing\\Router::toResponse()
 monicahq_1  | #7 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(695): Illuminate\\Routing\\Router->prepareResponse()
 monicahq_1  | #8 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(128): Illuminate\\Routing\\Router->Illuminate\\Routing\\{closure}()
 monicahq_1  | #9 /var/www/html/app/Http/Controllers/Api/ApiController.php(80): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
 monicahq_1  | #10 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): App\\Http\\Controllers\\Api\\ApiController->App\\Http\\Controllers\\Api\\{closure}()
 monicahq_1  | #11 /var/www/html/app/Http/Middleware/CheckLocale.php(28): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
 monicahq_1  | #12 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): App\\Http\\Middleware\\CheckLocale->handle()
 monicahq_1  | #13 /var/www/html/vendor/laravel/framework/src/Illuminate/Auth/Middleware/Authenticate.php(44): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
 monicahq_1  | #14 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Auth\\Middleware\\Authenticate->handle()
 monicahq_1  | #15 /var/www/html/app/Http/Middleware/SentryContext.php(43): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
 monicahq_1  | #16 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): App\\Http\\Middleware\\SentryContext->handle()
 monicahq_1  | #17 /var/www/html/app/Http/Middleware/ThrottleRequestsMiddleware.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
 monicahq_1  | #18 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): App\\Http\\Middleware\\ThrottleRequestsMiddleware->handle()
 monicahq_1  | #19 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
 monicahq_1  | #20 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(697): Illuminate\\Pipeline\\Pipeline->then()
 monicahq_1  | #21 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(672): Illuminate\\Routing\\Router->runRouteWithinStack()
 monicahq_1  | #22 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(636): Illuminate\\Routing\\Router->runRoute()
 monicahq_1  | #23 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(625): Illuminate\\Routing\\Router->dispatchToRoute()
 monicahq_1  | #24 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(166): Illuminate\\Routing\\Router->dispatch()
 monicahq_1  | #25 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(128): Illuminate\\Foundation\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure}()
 monicahq_1  | #26 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
 monicahq_1  | #27 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ConvertEmptyStringsToNull.php(31): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle()
 monicahq_1  | #28 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\ConvertEmptyStringsToNull->handle()
 monicahq_1  | #29 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
 monicahq_1  | #30 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TrimStrings.php(40): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle()
 monicahq_1  | #31 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\TrimStrings->handle()
 monicahq_1  | #32 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
 monicahq_1  | #33 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize->handle()
 monicahq_1  | #34 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php(86): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
 monicahq_1  | #35 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\PreventRequestsDuringMaintenance->handle()
 monicahq_1  | #36 /var/www/html/vendor/fideloper/proxy/src/TrustProxies.php(57): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
 monicahq_1  | #37 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Fideloper\\Proxy\\TrustProxies->handle()
 monicahq_1  | #38 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
 monicahq_1  | #39 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(141): Illuminate\\Pipeline\\Pipeline->then()
 monicahq_1  | #40 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(110): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter()
 monicahq_1  | #41 /var/www/html/public/index.php(55): Illuminate\\Foundation\\Http\\Kernel->handle()
 monicahq_1  | #42 {main}
 monicahq_1  | "}
@mgrhm
Copy link

mgrhm commented Aug 13, 2021

I have this same problem on 3.1.3.

The contact in question has 13 gifts already recorded. I create the gift, Monica reports that it's been successfully created but doesn't display it. The tab heading count of gifts does not increase -- it stays at "Gifts given (13)".

These appear to be getting added to the database, though. I looked at a copy of the SQL file and all three attempts were successful in creating a database entry:

 (112,1,12,'Box of Milkies',NULL,'https://smile.amazon.co.uk/dp/B012H5THFO/',99,3,'offered','2021-08-11 00:00:00','2021-08-11 07:40:10','2021-08-11 07:40:10'),
 (113,1,12,'Box of Milkies',NULL,'https://smile.amazon.co.uk/dp/B012H5THFO/',99,3,'offered','2021-08-11 00:00:00','2021-08-11 07:41:00','2021-08-11 07:41:00'),
 (114,1,12,'Box of Milkies',NULL,0,3,'offered','2021-08-13 00:00:00','2021-08-13 12:35:41','2021-08-13 12:35:41');

particleflux added a commit to particleflux/monica that referenced this issue Oct 1, 2021
Attempting to connect a photo to a gift, either an already existing one
or a freshly uploaded one, the AJAX call would return a 500 server
error. The error states of a `Attempt to read property "id" on null` in
`app\Http\Resources\Gift/Gift` line 24.

This is causes by attempting to use a void result of
`AssociatePhotoToGift` service in `ApiGiftController::associate()`
method.

Fixed by returning the actual `$gift` variable worked on, similar to the
related services.

This does fix the *stacktrace* in monicahq#5516, but not the issue itself. The
issue there is likely unrelated to the stacktrace.

Fixes monicahq#5397
particleflux added a commit to particleflux/monica that referenced this issue Oct 1, 2021
Attempting to connect a photo to a gift, either an already existing one
or a freshly uploaded one, the AJAX call would return a 500 server
error. The error states of a `Attempt to read property "id" on null` in
`app\Http\Resources\Gift/Gift` line 24.

This is causes by attempting to use a void result of
`AssociatePhotoToGift` service in `ApiGiftController::associate()`
method.

Fixed by returning the actual `$gift` variable worked on, similar to the
related services.

This does fix the *stacktrace* in monicahq#5516, but not the issue itself. The
issue there is likely unrelated to the stacktrace.

Fixes monicahq#5397
particleflux added a commit to particleflux/monica that referenced this issue Oct 1, 2021
Attempting to connect a photo to a gift, either an already existing one
or a freshly uploaded one, the AJAX call would return a 500 server
error. The error states of a `Attempt to read property "id" on null` in
`app\Http\Resources\Gift/Gift` line 24.

This is causes by attempting to use a void result of
`AssociatePhotoToGift` service in `ApiGiftController::associate()`
method.

Fixed by returning the actual `$gift` variable worked on, similar to the
related services.

This does fix the *stacktrace* in monicahq#5516, but not the issue itself. The
issue there is likely unrelated to the stacktrace.

Fixes monicahq#5397
@asbiin asbiin added the bug label Oct 2, 2021
asbiin pushed a commit that referenced this issue Oct 8, 2021
Attempting to connect a photo to a gift, either an already existing one
or a freshly uploaded one, the AJAX call would return a 500 server
error. The error states of a `Attempt to read property "id" on null` in
`app\Http\Resources\Gift/Gift` line 24.

This is causes by attempting to use a void result of
`AssociatePhotoToGift` service in `ApiGiftController::associate()`
method.

Fixed by returning the actual `$gift` variable worked on, similar to the
related services.

This does fix the *stacktrace* in #5516, but not the issue itself. The
issue there is likely unrelated to the stacktrace.

Fixes #5397
@mgrhm
Copy link

mgrhm commented Oct 8, 2021

Hi @asbiin. I don’t know if #5547 does fix this – the issue I’m having still exists. I create a new gift, and it doesn’t appear. The count of ‘Gifts Given’ stays at 13.

@particleflux
Copy link

It solves the original issue here though.

Your issue is kinda unrelated, but I can also reproduce this. Seems that the endpoint called to render the gifts is returning with a per_page of 15, so after 15 gifts (summed up ideas + received + given) per person it will no longer update either the count, nor the gifts list.

This is kinda a whole different thing though, since it is not related to the gift creation with photo upload failing. It also would require a new feature to handle that amount of gifts, like pagination. See #4739 for the related feature request.

@github-actions
Copy link

github-actions bot commented Oct 9, 2021

🎉 This issue has been resolved in version 3.3.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions
Copy link

This issue has been automatically locked since there
has not been any recent activity after it was closed.
Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants