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

Input validation to handle 502 Errors #87

Merged

Conversation

daralynnrhode
Copy link
Contributor

@daralynnrhode daralynnrhode commented Sep 7, 2024

Adding input validation for some parameters to avoid 502 errors

Overview

Input validation code for all input parameters. This should avoid most if not all 502 errors triggered when incorrect data is passed to the query and it crashes.
Also introduced a test to iterate over bad input values and check that the correct valueError message is returned.

Closes #55

New Dependencies

New Files

Deleted Files

Updated Files

  • io.cli
  • tests/test_io.py

Testing

@daralynnrhode daralynnrhode self-assigned this Sep 7, 2024
@daralynnrhode
Copy link
Contributor Author

daralynnrhode commented Sep 10, 2024

I went in and made a small change to the test_io.py``query_parameters supplied to the tests. The version being supplied was 000 which does not adhere to the code I introduced. The new code requires version be passed in as v000.
I opted to change the test to reflect the formatting that was consistently being used, but I can aways reverse the change and update the code as well as any documentation. Although, this would require both documentation and output messages to be updated as well.

@bourque bourque added this to the Sept 2024 milestone Sep 16, 2024
@daralynnrhode daralynnrhode requested review from greglucas, a team, bourque, sdhoyt, maxinelasp and anamanica and removed request for a team September 17, 2024 22:33
@daralynnrhode daralynnrhode changed the title [WIP] Input validation to handle 502 Errors Input validation to handle 502 Errors Sep 17, 2024
Copy link
Contributor

@maxinelasp maxinelasp left a comment

Choose a reason for hiding this comment

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

Had a few comments, mostly moving to some shared pieces that makes your code cleaner :) Hopefully this can remove that ruff ignore statement too, no big deal if it doesn't though

imap_data_access/io.py Outdated Show resolved Hide resolved
imap_data_access/io.py Outdated Show resolved Hide resolved
imap_data_access/io.py Outdated Show resolved Hide resolved
imap_data_access/io.py Outdated Show resolved Hide resolved
imap_data_access/io.py Outdated Show resolved Hide resolved
imap_data_access/io.py Outdated Show resolved Hide resolved
imap_data_access/io.py Outdated Show resolved Hide resolved
tests/test_io.py Show resolved Hide resolved
Copy link
Contributor

@maxinelasp maxinelasp left a comment

Choose a reason for hiding this comment

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

There is one comment that needs updating but other than that, looks good! Thanks for making those changes!

imap_data_access/file_validation.py Outdated Show resolved Hide resolved
Copy link
Contributor

@bourque bourque left a comment

Choose a reason for hiding this comment

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

Awesome work here, this looks great! And great work on making that parameterized test. That is some advanced level unit testing 🔥

tests/test_io.py Outdated Show resolved Hide resolved
Copy link
Contributor

@greglucas greglucas left a comment

Choose a reason for hiding this comment

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

Looks great, just some very minor stylistic comments that you can take or leave.

imap_data_access/file_validation.py Outdated Show resolved Hide resolved
imap_data_access/file_validation.py Outdated Show resolved Hide resolved
imap_data_access/io.py Outdated Show resolved Hide resolved
tests/test_io.py Show resolved Hide resolved
Copy link
Contributor

@greglucas greglucas left a comment

Choose a reason for hiding this comment

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

Thanks for making those minor updates, I think it reads nicely now. I found one minor thing in the error string example that should be updated too, otherwise looks great!

and not file_validation.ScienceFilePath.is_valid_repointing(repointing)
):
raise ValueError(
"Not a valid repointing, use format repointing<num>,"
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove the ing and make it explicit how many numbers there has to be. (Update the actual code as well, I just noticed this in the test here)

Suggested change
"Not a valid repointing, use format repointing<num>,"
"Not a valid repointing, use format repointXXXXX,"

@daralynnrhode daralynnrhode merged commit f313518 into IMAP-Science-Operations-Center:main Sep 26, 2024
13 checks passed
@daralynnrhode daralynnrhode deleted the 502_errors branch September 26, 2024 20:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Data Access API 502 errors
4 participants