Skip to content

[Article] Related articles throw errors when main article has too much tags  #30

@GemN

Description

@GemN

How to reproduce
(prod env)

query {
  article(id: 459) {
    id
    slug
    relatedArticles(take: 4) {
      id
      slug
    }
  }
}

Description
When querying the API for an article with a huge amount of tags, it throws:

message: 'Unexpected error value: { name: "ApiError", message: "Invalid value for \\"query\\" parameter, expected string shorter than 512 bytes", status: 400, transporterStackTrace: [[Object]] }',

After investigating, related articles build a huge query based on the tags which throws when over than 512bytes.

query = await articleQueryFilter(
	query,
	{
		searchQuery_eq: article.title + " " + article.tags.join(" ")
	},
	sort,
)

Proposed solution
We started to discuss on discord limiting the amount of tags, and add an order of importance which could be a solution but meanwhile from a pure technical POV:

  • We can iterate over tags, check the tag length, adding it to the query if the query is < 512 bytes with the new tag.

To note that even if we limit the number of tags, we should aways check that the query is under 512 bytes to avoid errors since it's completely dynamic and based on the title name (no size limit at the moment) and tags (not individual size limit)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions