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

more robust validation of return value from destfnscript #1085

Merged
merged 3 commits into from
Jun 6, 2024

Conversation

petersilva
Copy link
Contributor

saw how inscrutable the error message was for Daniel, when his destfnscript had a problem.
wrapped it in a try/except and added minimal validation of the return value... give people a hint.

Copy link

github-actions bot commented Jun 3, 2024

Test Results

242 tests   234 ✅  19s ⏱️
  1 suites    8 💤
  1 files      0 ❌

Results for commit 7efabbf.

♻️ This comment has been updated with latest results.

@petersilva petersilva marked this pull request as ready for review June 3, 2024 21:04
@petersilva petersilva added bug Something isn't working enhancement New feature or request crasher Crashes entire app. labels Jun 3, 2024
@petersilva
Copy link
Contributor Author

petersilva commented Jun 3, 2024

here is the old "error message":


Traceback (most recent call last):
  File "/local/home/sarra/sr3/sarracenia/instance.py", line 248, in <module> i.start()
  File "/local/home/sarra/sr3/sarracenia/instance.py", line 239, in start self.running_instance.run()
  File "/local/home/sarra/sr3/sarracenia/flow/__init__.py", line 565, in run  self.filter()
  File "/local/home/sarra/sr3/sarracenia/flow/__init__.py", line 1020, in filter pstrip, flatten)
  File "/local/home/sarra/sr3/sarracenia/flow/__init__.py", line 928, in updateFieldsAccepted
    msg['new_file'] = self.sundew_getDestInfos(msg, maskFileOption, filename)
  File "/local/home/sarra/sr3/sarracenia/flow/__init__.py", line 746, in sundew_getDestInfos
    return destFileName + satnet + timeSuffix
TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'

and the instance crashes.

Copy link
Member

@reidsunderland reidsunderland left a comment

Choose a reason for hiding this comment

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

There's a change in behaviour. Before the instance would crash and the file wouldn't get sent. Now if the destfnscript crashes, the file gets sent with the original name.

Is that okay? Would it be better to reject the message?

@petersilva
Copy link
Contributor Author

I dunno what is best to do... if it crashed then it would be obvious that something is wrong... with a destfn script... I mean it will drop some files in the flow... I guess missing is easier to understand than named wrong?

ok.

@petersilva
Copy link
Contributor Author

OK... so the problem is that we aren't in mainline flow code... we are in the routine sundew_getDestInfos whose return value is the new file name... and that is called from updateFieldsAccepted... which has no return value...
how to signal, the message is broken... maybe setting an error field in the message?

@reidsunderland
Copy link
Member

That could work.

I'm not saying this is better, just an alternative option: sundew_getDestInfos is called from updateFieldsAccepted, and that is called in the filter method. The try/except could be moved into filter, and the messages could be rejected there?

@petersilva
Copy link
Contributor Author

somehow this is already in development branch... I'm confused... merged by some other merge... anyways I will try to make it return None, and have the various callers deal with that to do something smart.

@petersilva
Copy link
Contributor Author

OK... it returns None as the file name in the error case, and now the main routines do_download and do_send check for empty new_file and new_directory fields and reject them. Good?

@petersilva petersilva merged commit f983ae5 into development Jun 6, 2024
4 checks passed
@petersilva petersilva deleted the daniel_made_me_do_it branch June 6, 2024 18:55
Copy link
Member

@reidsunderland reidsunderland left a comment

Choose a reason for hiding this comment

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

yes, that's great. thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working crasher Crashes entire app. enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants