Reported on Slack by a user in this thread.
If a key in the user's provided expected_columns does not appear in the actual dataset, Python raises a KeyError with an error message that might not be immediately helpful to the user:
File "/app/ehrql/assurance.py", line 71, in validate
if (validation_result := validate_patient(patient_id, patient, query_results))
~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/ehrql/assurance.py", line 139, in validate_patient
if expected[k] != actual[k]
~~~~~~^^^
KeyError: 'reps_ids_differ'
We might want to catch the mismatch earlier and return a custom error message.