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

FunctionClauseError: no function clause matching in Contentful.Delivery.Assets.resolve_entity_response/1 #37

Closed
OldhamMade opened this issue May 18, 2020 · 1 comment · Fixed by #43
Assignees

Comments

@OldhamMade
Copy link
Contributor

The production endpoint seems to be returning a map with the following attributes:

%{
  "fields" => %{
    "file" => %{
      "contentType" => "image/png",
      "details" => %{
        "image" => %{"height" => 2000, "width" => 3000},
        "size" => 7423579
      },
      "fileName" => "foo-bar.png",
      "url" => "//images.ctfassets.net/.../.../.../foo-bar.png"
    },
    "title" => "foo-bar"
  },
  "sys" => %{
    "createdAt" => "2020-01-08T11:44:33.417Z",
    "environment" => %{
      "sys" => %{
        "id" => "master",
        "linkType" => "Environment",
        "type" => "Link"
      }
    },
    "id" => "...",
    "locale" => "en-GB",
    "revision" => 1,
    "space" => %{
      "sys" => %{
        "id" => "...",
        "linkType" => "Space",
        "type" => "Link"
      }
    },
    "type" => "Asset",
    "updatedAt" => "2020-01-08T11:44:33.417Z"
  }
}

But the function expects a minimum of:

%{
  "fields" => %{
    "description" => desc,
    "file" => %{
      "contentType" => content_type,
      "details" => details,
      "fileName" => file_name,
      "url" => url
    },
    "title" => title
  },
  "sys" => %{"id" => id, "revision" => rev}
}

It seems the production endpoint isn't returning a description for the Assets, which causes this function to break. Removing the "description" => desc, line resolves the issue.

@floriank
Copy link
Collaborator

Thank you for the report! I'll incorporate a fix - this originally happend since all my test data assets do indeed have descriptions.

floriank referenced this issue in floriank/contentful.ex Jun 10, 2020
I originally assumed these are required fields, but they are not.

Thanks @OldhamMade for reporting the issue.

Fixes #37
floriank referenced this issue in floriank/contentful.ex Jun 10, 2020
I originally assumed these are required fields, but they are not.

Thanks @OldhamMade for reporting the issue.

Fixes #37
@floriank floriank self-assigned this Jun 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants