Commit 72e61ee
authored
Fix file uploads (#1715)
This PR fixes the error encountered when using file uploading actions:
["Expected a file url or base64 with
mimeType"](https://github.com/openops-cloud/openops/blob/3f3b8285d26d332de896dbc330184130e800bb41/packages/engine/src/lib/variables/props-processor.ts#L196).
The error occurs even for valid file uploads due incorrect regex and
schema checks. The issue was not detected due to a faulty unit test
which is also addressed by this PR.
## Additional Notes
* Fixes regex rejecting valid mime types such as
`application/vnd.ms-visio.drawing`
* Fixes the Zod schema check for PropertyType.FILE to check for
`WorkflowFile` not `record<>`
* Fixes the unit-test that was incorrectly passing due to using the same
`displayName` for both test cases which caused the output to contain
only 1 error instead of 2.
## Testing Checklist
Check all that apply:
- [x] I tested the feature thoroughly, including edge cases
- [x] I verified all affected areas still work as expected
- [x] Automated tests were added/updated if necessary
- [x] Changes are backwards compatible with any existing data, otherwise
a migration script is provided
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
Fixes OPS-3230.
## Summary by CodeRabbit
* **Bug Fixes**
* Enhanced file data URL processing to support MIME types with extended
character formats.
* Improved file property validation with stricter type checking for
improved reliability.
* **Tests**
* Updated test naming for improved clarity in file validation scenarios.
<sub>✏️ Tip: You can customize this high-level summary in your review
settings.</sub>
<!-- end of auto-generated comment: release notes by coderabbit.ai -->1 parent 39b378a commit 72e61ee
3 files changed
Lines changed: 4 additions & 3 deletions
File tree
- packages/engine
- src/lib/variables
- processors
- test/services
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
| 34 | + | |
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| |||
192 | 193 | | |
193 | 194 | | |
194 | 195 | | |
195 | | - | |
| 196 | + | |
196 | 197 | | |
197 | 198 | | |
198 | 199 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
0 commit comments