Skip to content

Errhandling non dict values #3463

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

Merged
merged 4 commits into from
Mar 7, 2025
Merged

Conversation

sjanssen2
Copy link
Contributor

When in test mode, you populate the database with "" values for command_parameters of table qiita.processing_job here

('b0f36550-d97c-4dd5-ba1b-910470062801', '[email protected]', 1, '""'::json, 1),
('b13eefd1-12b7-4c3e-a380-94ec0a3f9f91', '[email protected]', 1, '""'::json, 1),
('469c27b7-81c4-4f41-b09d-149260961227', '[email protected]', 1, '""'::json, 1),
('6f198e33-b4ae-47e9-973b-bd5e0b06c353', '[email protected]', 1, '""'::json, 1),
('045eb36c-5144-4d54-a621-23eb5dc4d6ef', '[email protected]', 1, '""'::json, 1),

Thus, when logged in as [email protected], qiita will raise AttributeErrors like:

[E 250307 07:55:30 web:1669] Uncaught exception GET /user/jobs/ (172.27.0.16)
    HTTPServerRequest(protocol='https', host='localhost', method='GET', uri='/user/jobs/', version='HTTP/1.0', remote_ip='172.27.0.16')
    Traceback (most recent call last):
      File "/opt/conda/envs/qiita/lib/python3.9/site-packages/tornado/web.py", line 1590, in _execute
        result = method(*self.path_args, **self.path_kwargs)
      File "/opt/conda/envs/qiita/lib/python3.9/site-packages/tornado/web.py", line 3006, in wrapper
        return method(self, *args, **kwargs)
      File "/qiita/qiita_pet/handlers/user_handlers.py", line 380, in get
        response = user_jobs_get_req(self.current_user)
      File "/qiita/qiita_core/util.py", line 83, in wrapper
        return func(*args, **kwargs)
      File "/qiita/qiita_pet/handlers/api_proxy/user.py", line 40, in user_jobs_get_req
        'params': j.parameters.values,
      File "/qiita/qiita_db/processing_job.py", line 724, in parameters
        return qdb.software.Parameters.load(
      File "/qiita/qiita_db/software.py", line 1637, in load
        parameters.update(missing_in_user)
    AttributeError: 'str' object has no attribute 'update'

This problem might not occur in a production environment, but since the load function already handles wrong use of parameters, I thought it might complement the current mechanism to also raise a more speaking error in this situation.

@coveralls
Copy link

Coverage Status

coverage: 92.389% (-0.003%) from 92.392%
when pulling d6d910f on jlab:errhandling_nonDictValues
into ba13403 on qiita-spots:dev.

@antgonza
Copy link
Member

antgonza commented Mar 7, 2025

Good catch! That hasn't occurred to me! Do you think fixing the inserts by replacing the '' with '{}' would be a better solution?

@sjanssen2
Copy link
Contributor Author

I did so for my local DB and now have proper dicts as entries. This will raise the expected missing parameter errors, tough. IMHO it's not worth patching the test DB, but it might be good service to the user of the function to move the error management from a non-speaking python trace to a slightly more informative type of error

@antgonza antgonza merged commit d49339f into qiita-spots:dev Mar 7, 2025
4 checks passed
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.

3 participants