Skip to content

Add form variable checks #804

@ChinHairSaintClair

Description

@ChinHairSaintClair

Is your feature request related to a problem? Please describe.
Downstream processes pull data from CouchDB and push it through to SQL for reporting. Variable keys are used as column names. If these names exceed the allowed column length or match a reserved word, the process breaks. Because forms contain skip logic, these problematic vars don't come through consistently, which result in intermittent interruptions.

Additionally, a variable length warning could encourage implementers to consider their naming strategies more carefully. While brevity shouldn't come at the cost of losing context, overly verbose or unnecessarily deeply nested vars can also increase maintenance complexity and make referencing them throughout the project config more cumbersome.

Describe the solution you'd like
Reduce downstream issues related to reserved words and variable lengths by introducing limits and restrictions and promote cleaner project config.
I propose introducing the following structure to the form properties:

{
  "var_restrictions": {
    "warn_length": <int>,
    "error_length": <int>,
    "ignore_list": <array>,
    "reserved_list": <array>
  }
}

Their functions:

  • warn_length: Print a warning with a list of vars whose length exceeds this limit
  • error_length: Throw an error with a list of vars whose length exceeds this limit
  • ignore_list: Exclude specified entries from either warning or error checks
  • reserved_list: Throw an error, with list of relevant items, if any reserved entries match form variables.

Describe alternatives you've considered
NA

Additional context
Forum discussion:
https://forum.communityhealthtoolkit.org/t/form-variable-length-name-warning/5541

Metadata

Metadata

Labels

Type

No type
No fields configured for issues without a type.

Projects

Status

💻 In Progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions