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

Forms steps can be None but this is not always expected (related to form deletion/exports) #3145

Open
CharString opened this issue Jun 8, 2023 · 2 comments

Comments

@CharString
Copy link
Contributor

CharString commented Jun 8, 2023

Product versie / Product version

latest

Omschrijf het probleem / Describe the bug

class CanNavigateBetweenSubmissionStepsPermission(permissions.BasePermission):
"""
Check if the user is allowed to interact with a submission step if the previous submission steps are not completed.
"""
def has_object_permission(
self, request: Request, view: APIView, obj: SubmissionStep
) -> bool:
user = request.user
order = obj.form_step.order

In facc4ce we refactored Submission.form_step to be allowed to be null.

It's unclear to me if CanNavigateBetweenSubmissionStepsPermission can ever be on a code path after FormStep deletion.

I've noticed more spots in the code base that assume form_step to not be None

  • SubmissionState.get_submission_step

Stappen om te reproduceren / Steps to reproduce

No response

Verwacht gedrag / Expected behavior

No response

Screen resolution

None

Device

None

OS

None

Browser

No response

@CharString CharString added bug triage Issue needs to be validated. Remove this label if the issue considered valid. labels Jun 8, 2023
@sergei-maertens
Copy link
Member

sergei-maertens commented Jun 8, 2023

facc4ce#diff-745cdb363d090e925e35031945f4df15ebec1ecb43e8472911b5557b251b317cR135 should handle those cases where the form_step FK is deleted, it then ends up in the code path where it's loaded from historical data.

So submission_step.form_step should in practice never be None. This historical data thing was added specifically because all code assumes it can never be None. There is an edge case where no history data is available (that's was the bug why this stuff was made nullable, as it was a data loss bug due to cascading deletes), but by now all of those submissions should be gone due to the periodic cleanup of submissions for privacy reasons.

@joeribekker joeribekker changed the title Incorrectly handle None case? Forms steps can be None but this is not always expected (related to form deletion/exports) Jul 10, 2023
@joeribekker
Copy link
Contributor

Refinement: This is part of a bigger issue. Related to: #2305

@joeribekker joeribekker removed the triage Issue needs to be validated. Remove this label if the issue considered valid. label Jul 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants