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

Fix bad avScan migration leaving legacy object rather than array #2052

Merged

Conversation

PE39806
Copy link
Contributor

@PE39806 PE39806 commented Mar 18, 2025

Since migrating File.avScan to its own Scan mongo Document, migration script 009 fails due to using .get on a lean object (POJO i.e. not a hydrated Document) within an async forEach loop which is not awaited, resulting in 009 appearing to pass when it has failed. 012 would then fail as it expected File.avScan to be an array or undefined but was getting objects which it couldn't handle.

This PR fixes these problems by:

  • making the find in 009 no longer use lean
  • converting the async forEach loop to for ... of in 009
  • adding a backpatch for 009 into 012
  • making 012 save with a potential Mixed mongoose SchemaType by explicitly marking as modified

@PE39806 PE39806 added bug Something isn't working javascript Pull requests that update Javascript code labels Mar 18, 2025
@PE39806 PE39806 marked this pull request as ready for review March 18, 2025 14:03
@PE39806 PE39806 merged commit 46ac34a into main Mar 20, 2025
21 checks passed
@PE39806 PE39806 deleted the bugfix/fix-avscan-sometimes-being-object-rather-than-array branch March 20, 2025 12:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working javascript Pull requests that update Javascript code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants