Fix displayImage command and validation#2040
Conversation
- make input string validation include path chars - camelCase to snake_case object call in reducer - include type hint in img_num param to get it validated by resource handler
Just my two cents on this: I think it's better to be explicit as it helps when searching through the codebase for instance. I've had experiences with frameworks that do this sort of casing conversions in the past and it's always been a nightmare. Hopefully one day we can generate TypeScript types from the Pydantic models to avoid this sort of issues. |
Oh yeah, that would be the dream! ( life would already be better just having TS 😭) |
| bool: True if the string is valid, False otherwise. | ||
| """ | ||
| pattern = r"^[a-zA-Z0-9._]*$" | ||
| pattern = r"^[a-zA-Z0-9._/-]*$" |
There was a problem hiding this comment.
I have a doubt about /, where do you need that, I imagine for a path ?
We should perhaps have a specific validation made for paths, to avoid i.e ../../ and other sort of possibly "nasty" things ?
There was a problem hiding this comment.
The display_image(self, path: str, img_num: int) function expects a path to the images masterfile and the validator blocks it. I also think that it should be a different type of validation for this specific type, how do you propose to include this custom type?
More on
displayImageexecuteCommand. I've noticed that the adapterdisplay_imageis expecting the paramimg_numinstead ofimgNumand that it did'nt had a type annotation so it was never getting validated. Also, for thepatharg thevalidate_input_strdoes not handle the case if the string is a valid path string. So, for the changes:resource_handler??