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

Cannot create custom workflows with too many Subjects - aka Error 413, Payload too large #195

Open
shaunanoordin opened this issue May 29, 2020 · 3 comments
Labels

Comments

@shaunanoordin
Copy link
Member

Major Functionality Issue

Original report: https://zooniverse.freshdesk.com/a/tickets/3695

When attempting to create a WildCam Darién Lab or WildCam Gorongosa Lab assignment, a user will encounter an unhelpful generic error message IF their assignment has "too many" Subjects.

"Too many" Subjects in this case comes about to 25000 Subjects or more, a number that's easily achieved if the user doesn't activate any filters when selecting photos for the Assignment.

Technical Details

The actual error is that the https://education-api.zooniverse.org/assignments/ endpoint is returning a 413. However, the error message displayed to the user is a very generic (and misleading) Request has been terminated Possible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.

Testing

I tested creating a new Assignment on https://classroom.zooniverse.org/#/wildcam-gorongosa-lab/educators/classrooms/2595/assignments/new using zootester1 using macOS + Chrome.

Replication:

  • Go to WildCam Gorongosa Lab. Create a Classroom, then open the Create Assignment page.
  • Fill in all the Assignment details.
  • When selecting photos, select >= 25000 photos - this can easily be done by setting no filters
  • Click on the button to create the Assignment.
  • Expected: assignment is created and user is taken to the Classroom's Assignments list page.
  • Actual: no assignment is created, the Create Assignment page becomes an error page, and a generic error message appears as a notification: Something went wrong : Error: Request has been terminated Possible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.

Status

Major bug.

Short term solution is to add an error message specifically for the 413 status.

Long term solution... probably limit the number of Subjects a user can create per Assignment. There is no feasible reason to create a Workflow with more than 10,000 Subjects, really.

@shaunanoordin
Copy link
Member Author

Yuh oh, the fast fix (explanatory status message) wasn't working as well as I'd hoped. Problem is, for the specific response we're getting from the Education API (413), I can never seem to get a legit status code.

In superagent, the error object I catch() during wcc_teachers_createAssignment looks like this:

Screen Shot 2020-05-29 at 17 41 05

Upgrading to superagent 5.2.2 has the same issue.

Changing from superagent to the JavaScript Fetch API is just as bad, since the error object just becomes an error string, with a similarly generic error message.

(Fetch API implementation looked like this btw):

Effect('wcc_teachers_createAssignment', ({ selectedProgram, selectedClassroom, assignmentData, students = [], filters = {}, subjects = []}) => {
  ...

const req = new Request(`${config.root}/assignments/`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'Authorization': apiClient.headers.Authorization,
    },
    mode: 'cors',
    cache: 'default',
    body: JSON.stringify(requestBody),
  });

  return fetch(req)
  .then(res => {
    console.log('+++ RES: ', res)

    if (!response) { throw 'ERROR (ducks/wildcam-classrooms/ducks/wcc_teachers_createAssignment): No response'; }
    if (response.ok &&
        response.body && response.body.data) {
      Actions.wildcamClassrooms.setAssignmentsStatus(WILDCAMCLASSROOMS_DATA_STATUS.SUCCESS);
      return response.body.data;
    }
    throw 'ERROR (ducks/wildcam-classrooms/ducks/wcc_teachers_createAssignment): Invalid response';
  })
  .catch(err => {
    console.log('+++ ERR: ', err)

    Actions.wildcamClassrooms.setAssignmentsStatus(WILDCAMCLASSROOMS_DATA_STATUS.ERROR);
    Actions.wildcamClassrooms.setAssignmentsStatusDetails(err);
    showErrorMessage(err);
    throw(err);
  })
}

@shaunanoordin
Copy link
Member Author

Right, I'm aborting my plan for a quick error message. I'm going to try locking down the maximum number of subjects that can be selected in the Map Explorer form itself, though this will take a bit of time to build.

@srallen
Copy link
Contributor

srallen commented Jun 4, 2020

I've responded to the educator in the original report and asked that they use the filter for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants