ErrorException(code: 0): Subscription should have a content encoding at /app/vendor/minishlink/web-push/src/WebPush.php:120

Created on 4 September 2024, 2 months ago
Updated 19 September 2024, about 2 months ago

Problem/Motivation

The push-notification is throwing the error:

Drupal\\Core\\Entity\\EntityStorageException: Subscription should have a content encoding in Drupal\\Core\\Entity\\Sql\\SqlContentEntityStorage->save() (line 817 of /app/html/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php). {\"severity_level\":3,\"exception\":\"[object] (Drupal\\\\Core\\\\Entity\\\\EntityStorageException(code: 0): Subscription should have a content encoding at /app/html/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php:817)\\n[previous exception] [object] (ErrorException(code: 0): Subscription should have a content encoding at /app/vendor/minishlink/web-push/src/WebPush.php:120)\"}

The error happen because a subscription has the parameters empty and when the Subscription instance is created, the error happen.

Steps to reproduce

- Install Social PWA module
- Configure the push-notification
- Create an user and set the notification
- To force the error, change value field to 'a:1:{s:0:"";a:4:{s:8:"endpoint";s:0:"";s:3:"key";s:0:"";s:5:"token";s:0:"";s:7:"browser";s:14:"Apple - Safari";}}' from users_data table filtering 'social_pwa' to module field and 'subscription' to name field and uid for the user configured before
- Clear cache
- Try to send a push-notification to this user

Proposed resolution

Add a validation to check if the endpoint, key and token field has value, when one of these fields is empty a message should be logged and a return early should be added.

Remaining tasks

N/A

User interface changes

N/A

API changes

N/A

Data model changes

N/A

🐛 Bug report
Status

Fixed

Version

2.1

Component

Code

Created by

🇧🇷Brazil viniciusrp

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024