Skip to content

Conversation

@aaronjae22
Copy link
Collaborator

We were using dictionary-style access with square brackets: form.data['datasource']. This fails if someone hits the endpoint without providing all expected parameters.

In this updated code instead of using form.data['datasource'], we use form.data.get('datasource', '')
The .get() method:
- Returns the value if the key exists
- Returns the default value (empty string in our case) if the key doesn't exist
- Never raises a KeyError/MultiValueDictKeyError

datasource and datadest were also modified.

Closes #113

@aaronjae22 aaronjae22 self-assigned this Jan 20, 2025
@aaronjae22 aaronjae22 merged commit fb26c46 into main Jan 21, 2025
4 checks passed
@aaronjae22 aaronjae22 deleted the fixing-server-error branch January 21, 2025 16:21
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.

Server error - django.utils.datastructures.MultiValueDictKeyError: 'datasource'

3 participants