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

Prevent tasks linking to themselves #5925

Merged
merged 1 commit into from
Apr 13, 2021
Merged

Prevent tasks linking to themselves #5925

merged 1 commit into from
Apr 13, 2021

Conversation

eatyourgreens
Copy link
Contributor

@eatyourgreens eatyourgreens commented Mar 31, 2021

Add a task prop to the NextTaskSelector in the lab and pass down the current task. Filter the current task out of the list of next task options.

This turned out to be more complicated than I thought because each task (app/classifier/tasks) implements its own 'Next task' menu in its editor component. I think I got them all. You can check it by editing tasks in the project builder. You shouldn't be able to link any task back to itself any more.

Staging branch URL: https://pr-5925.pfe-preview.zooniverse.org

Fixes #2512.

Required Manual Testing

  • Does the non-logged in home page render correctly?
  • Does the logged in home page render correctly?
  • Does the projects page render correctly?
  • Can you load project home pages?
  • Can you load the classification page?
  • Can you submit a classification?
  • Does talk load correctly?
  • Can you post a talk comment?

Review Checklist

  • Does it work in all major browsers: Firefox, Chrome, Edge, Safari?
  • Does it work on mobile?
  • Can you rm -rf node_modules/ && npm install and app works as expected?
  • If the component is in coffeescript, is it converted to ES6? Is it free of eslint errors? Is the conversion its own commit?
  • Are the tests passing locally and on Travis?

Optional

Add a task prop to the NextTaskSelector in the lab and pass down the current task. Filter the current task out of the list of next task options.
@coveralls
Copy link

Coverage Status

Coverage increased (+0.005%) to 49.795% when pulling 8eec52d on lab-next-task into aaa2985 on master.

@eatyourgreens eatyourgreens requested a review from a team April 1, 2021 07:29
@shaunanoordin shaunanoordin self-assigned this Apr 13, 2021
@shaunanoordin shaunanoordin self-requested a review April 13, 2021 16:52
@shaunanoordin
Copy link
Member

I'm trying to think of scenarios where a Task WOULD like to link to themselves. Uh...

T0: Are we there yet? Are we there yet? Are we there yet?
Answer 0: No -> Go to T0
Answer 1: Yes -> Submit and move to next classification

That doesn't make sense, so it the "let's not allow tasks to link to themselves" rule is valid. Let me think of Combo Tasks...

@shaunanoordin
Copy link
Member

I suppose, in theory, it's possible somebody might want to create a combo task like...

T0: Do you see one or more muppets in this photo?
Yes -> go to T1 (combo task)
No -> submit

T1.0: Describe one of the muppets.
(Text)

T1.1: Is there another muppet you want to talk about?
Yes -> go to T1 (combo task)
No -> submit


EDIT: I've just tested this on PFE, and it's NOT possible to branch from a Combo task. A Combo Task on the PFE classifier has only ONE "Next Task", and ignores any "Next Task" logic of its children Tasks.

(Maybe I'm thinking of the front-end-monorepo... does that have more complicated branching logic?)

In any case, I see no logical reason for a Task to ever loop in on itself so immediately, so the goal of this PR is legit. I'll proceed with functionality tests next.


NOTE: It will still be possible to lock yourself in a two-step loop, e.g. T0 leads to T1, leads to T0, leads to T1, etc but this PR can only fix so much insanity.

@eatyourgreens
Copy link
Contributor Author

Ha! Every now and again we get a report of a broken workflow where it turns out the solution is that Next Task has been accidentally set to something other than ‘submit the classification’.

We could maybe have a check for that too. Might be complicated for branching workflows.

Copy link
Member

@shaunanoordin shaunanoordin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Review

This PR changes the Workflow editor page, preventing any given Task from setting its "next task" to be itself.

  • i.e. this PR prevents the workflow logic from looping endlessly on one task.
  • ⚠️ It is STILL possible to create a two-step loop, e.g. T0's next task is T1, and T1's next task is T0. This PR will not fix such a scenario, and trying to detect infinite loops in the logic is a gateway to madness.

Code read looks good, and functionality checks out.

Testing

Tested on localhost + macOS 10 + Chrome 89, using a random test project.

Replication steps

  • create 3 tasks, T0, T1, T2
  • for T0, look at the options available for "Next Task"
    • The list should include T1, T2, and "submit"
    • The list shouldn't include T0
  • Repeat for T0
  • Repeat for different Task types

Tests look good for the Task types: Question, Drawing, Text, Survey, Combo. I'm happy to give this a blanket 👍 for all task types.

Additional notes on testing further Task types:

  • Main logic change is in , which now requires a "current task" prop to check against.
  • A quick look through every use of in the repo indicates that this "current" task is being passed down properly.
  • This propagated logic seems legit, so a thorough test of e.g. Dropdown Task seems like overkill.

Status

LGTM! As noted in earlier comments, I don't see any logical reason for a Task to link to itself, so this PR goals are legit to me.

@eatyourgreens eatyourgreens merged commit 4dc080d into master Apr 13, 2021
@eatyourgreens eatyourgreens deleted the lab-next-task branch April 13, 2021 17:39
eatyourgreens added a commit to eatyourgreens/Panoptes-Front-End that referenced this pull request May 9, 2024
A second go at fixing this, previously fixed in zooniverse#5925. Pass the current task key as a prop to `NextTaskSelector`. Filter the list of tasks to exclude that task key, so that a task can't link back to itself.

This has to be edited in the editors for each individual task type, but I think I got them all.
eatyourgreens added a commit to eatyourgreens/Panoptes-Front-End that referenced this pull request May 9, 2024
A second go at fixing this, previously fixed in zooniverse#5925. Pass the current task key as a prop to `NextTaskSelector`. Filter the list of tasks to exclude that task key, so that a task can't link back to itself.

This has to be edited in the editors for each individual task type, but I think I got them all.
eatyourgreens added a commit to eatyourgreens/Panoptes-Front-End that referenced this pull request May 9, 2024
A second go at fixing this, previously fixed in zooniverse#5925. Pass the current task key as a prop to `NextTaskSelector`. Filter the list of tasks to exclude that task key, so that a task can't link back to itself.

This has to be edited in the editors for each individual task type, but I think I got them all.
eatyourgreens added a commit to eatyourgreens/Panoptes-Front-End that referenced this pull request May 19, 2024
A second go at fixing this, previously fixed in zooniverse#5925. Pass the current task key as a prop to `NextTaskSelector`. Filter the list of tasks to exclude that task key, so that a task can't link back to itself.

This has to be edited in the editors for each individual task type, but I think I got them all.
eatyourgreens added a commit to eatyourgreens/Panoptes-Front-End that referenced this pull request May 31, 2024
A second go at fixing this, previously fixed in zooniverse#5925. Pass the current task key as a prop to `NextTaskSelector`. Filter the list of tasks to exclude that task key, so that a task can't link back to itself.

This has to be edited in the editors for each individual task type, but I think I got them all.
eatyourgreens added a commit to eatyourgreens/Panoptes-Front-End that referenced this pull request Jun 1, 2024
A second go at fixing this, previously fixed in zooniverse#5925. Pass the current task key as a prop to `NextTaskSelector`. Filter the list of tasks to exclude that task key, so that a task can't link back to itself.

This has to be edited in the editors for each individual task type, but I think I got them all.
eatyourgreens added a commit to eatyourgreens/Panoptes-Front-End that referenced this pull request Jun 5, 2024
A second go at fixing this, previously fixed in zooniverse#5925. Pass the current task key as a prop to `NextTaskSelector`. Filter the list of tasks to exclude that task key, so that a task can't link back to itself.

This has to be edited in the editors for each individual task type, but I think I got them all.
eatyourgreens added a commit to eatyourgreens/Panoptes-Front-End that referenced this pull request Jun 8, 2024
A second go at fixing this, previously fixed in zooniverse#5925. Pass the current task key as a prop to `NextTaskSelector`. Filter the list of tasks to exclude that task key, so that a task can't link back to itself.

This has to be edited in the editors for each individual task type, but I think I got them all.
eatyourgreens added a commit to eatyourgreens/Panoptes-Front-End that referenced this pull request Jun 18, 2024
A second go at fixing this, previously fixed in zooniverse#5925. Pass the current task key as a prop to `NextTaskSelector`. Filter the list of tasks to exclude that task key, so that a task can't link back to itself.

This has to be edited in the editors for each individual task type, but I think I got them all.
eatyourgreens added a commit to eatyourgreens/Panoptes-Front-End that referenced this pull request Nov 19, 2024
A second go at fixing this, previously fixed in zooniverse#5925. Pass the current task key as a prop to `NextTaskSelector`. Filter the list of tasks to exclude that task key, so that a task can't link back to itself.

This has to be edited in the editors for each individual task type, but I think I got them all.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants