Skip to content
This repository has been archived by the owner on Apr 16, 2024. It is now read-only.

Course list broken when course image in invalid state #1053

Closed
1 task
kesselb opened this issue Dec 3, 2018 · 0 comments
Closed
1 task

Course list broken when course image in invalid state #1053

kesselb opened this issue Dec 3, 2018 · 0 comments
Assignees

Comments

@kesselb
Copy link
Contributor

kesselb commented Dec 3, 2018

Steps to reproduce

  1. Upload a course image
  2. Delete the image object from file table (e.g. mongocli)
  3. It's not possible to render list view for student/teacher/admin
TypeError: Cannot read property 'toObject' of null
    at model.<anonymous> (/home/daniel/Code/geli/api/build/src/models/Course.js:284:82)
    at Generator.next (<anonymous>)
    at fulfilled (/home/daniel/Code/geli/api/build/src/models/Course.js:4:58)

const image = (this.image) ? (await Picture.findById(this.image)).toObject() : null;

I'm not sure if its possible to force this error somehow (i did but can't remeber how). Code above checks if course.image is not null but not if there is a matching object in file table (not null) before calling toObject.

Acceptance criteria:

  • No unsafe access
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant