Problem/Motivation

When tooting from an entity the following error is encountered.

Error: Call to a member function getFileUri() on null in Drupal\mastodon_api_entity\Form\MastodonApiEntityPushForm->submitForm() (line 306 of modules/contrib/mastodon_api/modules/mastodon_api_entity/src/Form/MastodonApiEntityPushForm.php).

Steps to reproduce

Install the Mastodon API entity module.
Configure the entity module to attach to one of the content entities, eg, Content Types.
Select one of the available image fields for the content type.
Attempt to send a toot using the image.
See error.

Proposed resolution

It looks like we are just missing a connection between the media item and the image. The file entity isn't being loaded and that also isn't being checked by the module.

This is a good opportunity to add a more complex test to the module since the mastodon api entity form has a lot of moving parts.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

philipnorton42 created an issue. See original summary.

philipnorton42’s picture

The created MR solves the problem.

But I'm going to write a test anyway since it's a complex form with a few moving parts that needs a decent test for silly mistakes like this.

philipnorton42’s picture

Status: Active » Fixed

It turns out I _had_ written a test for this form, but only to check that the formatting plugins worked, so I just needed to add a step to submit the form.

To make sure I could submit the form in test mode I created a mastodon_api_stub module that swaps out the main mastodon_api service for one that never uses the API. This means I can test things without posting anything to mastodon.

As everything is checking out I'll close this issue.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

philipnorton42’s picture

Status: Fixed » Closed (fixed)