On import of a tar file from configuration form I get this error:

Type .../rest/type/user/user does not correspond to an entity on this site.

No error unzipping the same file in the content folder and running the command via terminal (dcdi --force-override --preserve-password)

Data are imported but the error is weird.

The File Import Does not happen with Better Normalizer Module.

Comments

simoneb created an issue. See original summary.

miroslav-lee’s picture

Could you install the latest version of the module itself and test it again, please?

simoneb’s picture

Tested with latest beta but I'm still getting same type of errors, type is random.

Type http://xxxx/rest/type/paragraph/text does not correspond to an entity on this site.
Type http://xxxx/rest/type/content_moderation_state does not correspond to an entity on this site.
Type http://xxxx/rest/type/paragraph/erl_section does not correspond to an entity on this site.
...

I'd to set time limit to 0 in default_content importer as the import works only for small files

simoneb’s picture

I get results like:

Created: 28
Updated: 2
Skipped: 0
Error message Type http://xxxx/rest/type/user/user does not correspond to an entity on this site.

Of course nothing is imported.

Same file, unzipped into content folder and imported with: dcdi --preserve-password --force-override

works

simoneb’s picture

Last test
I exported the site to local content folder using EXPORT SITE UI (about 500 nodes)

I tried to import them (no force override) and I got:

created: 0
updated: 1195
skipped: 988

with error Type http://192.168.0.18/rest/type/shortcut/default does not correspond to an entity on this site.

I'm not sure that it should have updated 1195 objects as there have been no changes between the two but... btw, it's not the focus of the issue

Tried to import via terminal with: drush dcdi --preserve-password and I got

same numbers before confirmation

- created: 0
- updated: 1195
- skipped: 988

and I was able to import (I had to remove the content_moderation_state folder due to the Error: Call to undefined method stdClass::save() in Drupal\content_moderation\Entity\ContentModerationState->save() issue)

In this case, I got: [OK] Content has been imported.

simoneb’s picture

Debugging a bit, the error is fired by this function

  /**
   * Gets the typed data IDs for a type URI.
   *
   * @param array $types
   *   The type array(s) (value of the 'type' attribute of the incoming data).
   * @param array $context
   *   Context from the normalizer/serializer operation.
   *
   * @return array
   *   The typed data IDs.
   */
  protected function getTypedDataIds($types, $context = []) {
    // The 'type' can potentially contain an array of type objects. By default,
    // Drupal only uses a single type in serializing, but allows for multiple
    // types when deserializing.
    if (isset($types['href'])) {
      $types = [$types];
    }

    if (empty($types)) {
      throw new UnexpectedValueException('No entity type(s) specified');
    }

    foreach ($types as $type) {
      if (!isset($type['href'])) {
        throw new UnexpectedValueException('Type must contain an \'href\' attribute.');
      }

      $type_uri = $type['href'];

      // Check whether the URI corresponds to a known type on this site. Break
      // once one does.
      if ($typed_data_ids = $this->linkManager->getTypeInternalIds($type['href'], $context)) {
        break;
      }
    }

    // If none of the URIs correspond to an entity type on this site, no entity
    // can be created. Throw an exception.
    if (empty($typed_data_ids)) {
      throw new UnexpectedValueException(sprintf('Type %s does not correspond to an entity on this site.', $type_uri));
    }

    return $typed_data_ids;
  }

in web/core/modules/hal/src/Normalizer/ContentEntityNormalizer.php line 268

simoneb’s picture

StatusFileSize
new1.04 KB

Ok, after a long debug I found the issue

  /**
   * Change to current host in a config file.
   *
   * @param $pattern
   * @param $pattern_link
   * @param $data
   */
  private function replaceHost($pattern, $pattern_link, &$data) {
    $host = $this->request->getHttpHost();
    preg_match_all($pattern, $data, $match);

    foreach ($match[0] as $origin_str) {
      preg_match($pattern_link, $origin_str, $match_host);

      if (!empty($match_host)) {
        $valid_str = str_replace($match_host[1], $host, $origin_str);
        $data = str_replace($origin_str, $valid_str, $data);
      }
    }
  }

in src/Importer.php is using getHttpHost that doesn't return the site path if it's installed in a subfolder (it's my case)

I've created a patch for it and seems working

simoneb’s picture

Something is still wrong, on HTTPS it still does not work (probably because the schema is set to HTTP by default)

Also, if I try to import a simple Article with a Tag, both are created but not linked.

All these issues from the UI only, from command line all work perfectly

miroslav-lee’s picture

Status: Active » Needs review

Thank you very much for this work, I will look at this patch later.

rakshith.thotada’s picture

StatusFileSize
new4.35 KB

I have provided with the patch with custom Normaliser for default content - that takes care of the above issue. Please review.

rakshith.thotada’s picture

StatusFileSize
new4.87 KB

Updated The Patch with a fix for issue https://www.drupal.org/project/default_content_deploy/issues/3130782 as well

rakshith.thotada’s picture

StatusFileSize
new9.53 KB
rakshith.thotada’s picture

StatusFileSize
new10.15 KB

Updating the patch with recent changes related to issue https://www.drupal.org/project/default_content_deploy/issues/3130782

rakshith.thotada’s picture

Title: Type User does not correspond to an entity on this site » Type User does not correspond to an entity on this site also File Import does not work with better Normalizers
Issue summary: View changes
StatusFileSize
new12.19 KB

Patch to integrate with Better Normalizer Module.

rakshith.thotada’s picture

StatusFileSize
new6.14 KB

I found the File entity Normalizer takes care of itself - we just need to decorate TypeLinkManager service to overcome the above issue.

rakshith.thotada’s picture

StatusFileSize
new10.99 KB

Updated the patch to consider References for all entities.

rakshith.thotada’s picture

StatusFileSize
new12.4 KB

Updating the Patch with Final fix.

rakshith.thotada’s picture

StatusFileSize
new16.39 KB

Updated the patch to work with internal links.

miroslav-lee’s picture

@simoneb Could you check the last patch from @rakshith.thotada, please?

miroslav-lee’s picture

But I think your patch do a global changes. I attached patch with small fixes.
Test please

axel80’s picture

I tested patch #20, the issue is resolved and the content is imported successfully

  • miroslav-lee committed 1b6f020 on 8.x-1.x
    Issue #3127786 by rakshith.thotada, simoneb, miroslav-lee: Type User...
miroslav-lee’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

priya sundharam’s picture

Hi Team,

Do we have any patch for Drupal9 for the same issue as above patch is not compatible with D9?

Thanks

simoneb’s picture

According to this commit https://www.drupal.org/commitlog/commit/92827/1b6f020f7954d410dfbb78a6e2... it should have been ported to 2.0.x. Am I wrong?