Skip to content

Validate persisted revisions before workflow transitions - #738

Open
jhunterjActual wants to merge 5 commits into
GrandComicsDatabase:betafrom
jhunterjActual:fix/validate-changeset-submit
Open

Validate persisted revisions before workflow transitions#738
jhunterjActual wants to merge 5 commits into
GrandComicsDatabase:betafrom
jhunterjActual:fix/validate-changeset-submit

Conversation

@jhunterjActual

@jhunterjActual jhunterjActual commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Validate persisted issue and story revisions before submission and immediately before approval.
  • Reuse the existing forms and formsets as the validation source of truth, including database-object Features values.
  • Keep invalid submissions in the indexer's workflow and block invalid approvals with guidance.

Root cause

Revision data can be changed through migrations or other non-form code paths and then submitted without passing through the normal edit-form validation. Submission and approval previously trusted that persisted data, allowing (for example) invalid mixed text and database object Features data to be submitted and approved.

User impact

Indexers receive linked validation errors and can correct the persisted data before submission. Editors cannot approve invalid data and are directed to send back to indexer for the required correction. Validation failures do not partially commit changes.

Validation

  • Focused tests: 10 passed
  • Flake8 passed for all changed Python files
  • Changed templates compiled successfully
  • Docker-configured manage.py check passed
  • git diff --check passed
  • Manual UAT passed for valid Features submission, invalid persisted data, send-back, correction, and approval

Closes #572

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a validation mechanism for persisted revisions before changeset workflow transitions, along with synchronized workflow action labels across buttons and instructions. It adds validation logic, corresponding unit tests, and updates views and templates to use the new labels and validate changesets before submission or approval. Feedback on these changes highlights three key areas for improvement: handling potential None values for min_num and max_num in formsets to avoid Django validation errors, adding a defensive guard in _send_notification to prevent AttributeError when user is None, and refactoring the formset validation loop to avoid relying on subtle non-short-circuiting behavior of the and operator.

Comment thread apps/oi/submission_validation.py Outdated
Comment thread apps/oi/views.py Outdated
Comment thread apps/oi/submission_validation.py Outdated
For readability and future refactoring safety

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@jhunterjActual
jhunterjActual marked this pull request as ready for review August 6, 2026 19:55
@jhunterjActual

Copy link
Copy Markdown
Contributor Author

Note that 2 of Gemini Code Assist's 3 feedback items were not implemented. Details in those comments.

Comment thread apps/oi/views.py Outdated
@gcd-github

gcd-github commented Aug 7, 2026 via email

Copy link
Copy Markdown

@jhunterjActual

Copy link
Copy Markdown
Contributor Author

I probably do not understand this, but would "...explicitly rejects any changeset without an approver..." result in a failure if someone commented on a changeset directly from the Pending list, that does not yet have an approver assigned?  We often have folks, some not editors, who make such comments. - Don Milne

Ordinary Add Comment activity isn't affected. It uses a separate path that leaves the changeset in its existing state and does not require an approver. On an unassigned pending changeset, it records the comment, notifies the indexer and prior commenters, and skips the approver notification because none exists.

Comment thread apps/oi/submission_validation.py Outdated
Comment thread apps/oi/submission_validation.py Outdated
@gcd-github

gcd-github commented Aug 7, 2026 via email

Copy link
Copy Markdown

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

Successfully merging this pull request may close these issues.

form checks on submit to queue

3 participants