Skip to content

Graphql Exception "Category image not found" if image doesn't exist shouldn't error the entire request #34266

Closed
@iba-1

Description

@iba-1

Summary (*)

When trying to get a list of categories, or even only one category, if "image" field is filled but the image can't be found on filesystem the request will fail with "Error: Category image not found."
This shouldn't be the correct behavior as not being able to render an image for a category isn't an unrecoverable error, and we've been able to handle in frontend this kind of errors for years, either be using a fallback or by leveraging other solutions.
Plus, when displaying a list of categories an image missing shouldn't block the whole categories being displayed by erroring the request.

Examples (*)

  • Upload an image to a category
  • Delete it from FS
  • Run any categories Graphql query including "image" attribute
  • Watch it fail by "Error: Category image not found."

In our case, this was the query:

const QUERY = gql`
  query GetLines {
    categories {
      items {
        children {
          name
          children {
            name
            children {
              name
              fast_shipping
              url_path
              image
            }
          }
        }
      }
    }
  }
`;

Proposed solution

Remove entirely this exception:

if (!$this->fileInfo->isExist($filenameWithMedia)) {
throw new GraphQlInputException(__('Category image not found.'));
}


Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.

  • Severity: S0 - Affects critical data or functionality and leaves users with no workaround.

No workaround that we can think of can be applied to recover from this error apart from re-uploading the missing image.

Metadata

Metadata

Assignees

Labels

Area: CatalogComponent: CatalogGraphQlIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedPriority: P1Once P0 defects have been fixed, a defect having this priority is the next candidate for fixing.Progress: doneProject: GraphQLReproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branchSeverity: S0A problem that is blocking the ability to work. An immediate fix is needed.Triage: Dev.ExperienceIssue related to Developer Experience and needs help with Triage to Confirm or Reject it

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions