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

#669: reject form with unknown columns in entities sheet #671

Merged
merged 1 commit into from
Nov 29, 2023

Conversation

lindsay-stevens
Copy link
Contributor

Closes #669

Why is this the best possible solution? Were any other approaches considered?

This adds to the existing entities validation in the parsing module. The approach is to create an enum with the allowed column names, and if any extra columns are found, raise an error naming the unexpected columns. I went through and updated internal string usages to reference the constants module to ensure that the keys are consistent (this typing could be done with a class but workbook_to_json emits a dict).

What are the regression risks?

Users may now get an error if they have already created forms where they have used annotation columns like those allowed in other XLSForm sheets. The Entities sheet is now "strict" in the sense that it only allows certain columns now.

Does this change require updates to documentation? If so, please file an issue here and include the link below.

Probably not, the documentation would already say which columns are required / allowed.

Before submitting this PR, please make sure you have:

  • included test cases for core behavior and edge cases in tests
  • run nosetests and verified all tests pass
  • run black pyxform tests to format code
  • verified that any code or assets from external sources are properly credited in comments

- add tests for new error case(s) + happy path
- add copy of python 3.11 StrEnum which can reference members as str
- add enum with the expected entities column names
- update existing entities modules to use constants
Copy link
Contributor

@lognaturel lognaturel left a comment

Choose a reason for hiding this comment

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

YES!

@lognaturel lognaturel merged commit 01e9feb into XLSForm:master Nov 29, 2023
10 checks passed
@lindsay-stevens lindsay-stevens deleted the pyxform-669 branch November 29, 2023 02:09
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.

Reject form with unknown columns in entities sheet
2 participants