Skip to content

test: Coverage of database update error handling varies between CI runs - #10727

Merged
mtrezza merged 1 commit into
parse-community:alphafrom
mtrezza:test/update-error-coverage
Sep 29, 2026
Merged

mtrezza merged 1 commit into
parse-community:alphafrom
mtrezza:test/update-error-coverage

Conversation

@mtrezza

@mtrezza mtrezza commented Sep 29, 2026 •

Copy link
Copy Markdown
Member

Pull Request

Issue

codecov/project fails on many pull requests because 3 lines in the error handling of the database adapters are covered in some CI runs but not in others: lines 1868 and 1887 in updateObjectsByQuery of src/Adapters/Storage/Postgres/PostgresStorageAdapter.js, and line 690 in findOneAndUpdate of src/Adapters/Storage/Mongo/MongoStorageAdapter.js. No spec causes an update error other than a duplicate value error, so these lines are only reached by chance. On Postgres, this happens when a background _PushStatus update of a push spec runs after afterEach has dropped the tables; the cause for the MongoDB line wasn't reproduced. Since April, these were the only lines that varied between CI runs with all coverage uploads, and they caused 19 of the 23 codecov/project failures on pull requests created from July 1.

Closes #10726, part of #10681.

Approach

  • findOneAndUpdate rethrows errors other than unique violation errors in spec/PostgresStorageAdapter.spec.js updates a class that has no table, and expects the Postgres error 42P01 (relation does not exist) instead of a Parse.Error.
  • findOneAndUpdate rethrows errors other than duplicate key errors in spec/MongoStorageAdapter.spec.js lets the findOneAndUpdate of the MongoDB driver reject with an error other than a duplicate key error, and expects the adapter to reject with the same error.
  • The 3 lines are therefore covered in every run of the PostgreSQL and MongoDB test jobs. The push specs are not changed; their late _PushStatus updates can still fail in some runs, but no longer change the coverage.

As decided in #10726, codecov/project keeps reporting on pull requests and failing if the coverage decreases, and codecov/patch stays as it is. Making codecov/project informational, turning it off, or adding a threshold was considered, but any threshold that tolerates the variation of 1 to 3 lines would also have tolerated the coverage losses that only codecov/project reported, such as in #10498 and #10543. If another line starts varying between CI runs, it can be covered the same way. Once alpha has shown no varying lines for a while, codecov/project can become a required check on alpha, as it already is on release and release-8.x.x. A decrease caused by a failed or cancelled test job, which doesn't upload its coverage, remains until the job is re-run.

Verified locally with MongoDB 8.0 and PostgreSQL 16:

  • A coverage run of the new specs alone covers the 3 lines.
  • Each spec fails if the adapter converts the error into a Parse.Error, also if it keeps the error message, or if it handles the error as a duplicate value error.
  • All specs in spec/PostgresStorageAdapter.spec.js and spec/MongoStorageAdapter.spec.js pass.

Tasks

  • Add tests
  • Add changes to documentation (guides, repository pages, code comments)
  • Add security check
  • Add new Parse Error codes to Parse JS SDK

Summary by CodeRabbit

  • Tests
    • Added regression coverage confirming that MongoDB and PostgreSQL storage errors retain their original error codes when findOneAndUpdate fails.

@parse-github-assistant

Copy link
Copy Markdown

🚀 Thanks for opening this pull request! We appreciate your effort in improving the project. Please let us know once your pull request is ready for review.

Tip

  • Keep pull requests small. Large PRs will be rejected. Break complex features into smaller, incremental PRs.
  • Use Test Driven Development. Write failing tests before implementing functionality. Ensure tests pass.
  • Group code into logical blocks. Add a short comment before each block to explain its purpose.
  • We offer conceptual guidance. Coding is up to you. PRs must be merge-ready for human review.
  • Our review focuses on concept, not quality. PRs with code issues will be rejected. Use an AI agent.
  • Human review time is precious. Avoid review ping-pong. Inspect and test your AI-generated code.

Note

Please respond to review comments from AI agents just like you would to comments from a human reviewer. Let the reviewer resolve their own comments, unless they have reviewed and accepted your commit, or agreed with your explanation for why the feedback was incorrect.

Caution

Pull requests must be written using an AI agent with human supervision. Pull requests written entirely by a human will likely be rejected, because of lower code quality, higher review effort and the higher risk of introducing bugs. Please note that AI review comments on this pull request alone do not satisfy this requirement. Our CI and AI review are safeguards, not development tools. If many issues are flagged, rethink your development approach. Invest more effort in planning and design rather than using review cycles to fix low-quality code.

@coderabbitai

coderabbitai Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Essentials

Run ID: f97812c8-cf2c-4159-9bde-802908d3d794

📥 Commits

Reviewing files that changed from the base of the PR and between 6145e7f and ebd6474.

📒 Files selected for processing (2)
  • spec/MongoStorageAdapter.spec.js
  • spec/PostgresStorageAdapter.spec.js

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

Added MongoDB and PostgreSQL regression tests that check findOneAndUpdate rejects with the original error for non-duplicate database error codes.

Changes

Adapter Error Propagation

Layer / File(s) Summary
Non-duplicate database error tests
spec/MongoStorageAdapter.spec.js, spec/PostgresStorageAdapter.spec.js
The MongoDB test checks that error code 2 is returned. The PostgreSQL test checks that a missing relation error with code 42P01 is returned.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~8 minutes

Merge Risk: ⚪ Minimal · up to ebd64

This change adds regression coverage for database error propagation without changing adapter behavior. No actionable merge-blocking risk was identified.

🚥 Pre-merge checks | ✅ 7
✅ Passed checks (7 passed)
Check name Status Explanation
Title check ✅ Passed The title begins with the allowed prefix test: and clearly describes the added database error-handling coverage tests.
Description check ✅ Passed The description follows the repository template. It explains the issue, approach, test coverage, verification, and completed tasks.
Linked Issues check ✅ Passed Issue #10726 asks for a decision about the existing codecov/project behavior. The PR keeps that check reporting and failing on coverage decreases. The added PostgreSQL and MongoDB tests cover the da…
Out of Scope Changes check ✅ Passed The PR changes only spec/MongoStorageAdapter.spec.js and spec/PostgresStorageAdapter.spec.js. Each test targets the database error-handler coverage variation described in issue #10726. The changes…
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
Security Check ✅ Passed The pull request changes only two test files; no production or exported code changed. The added tests use a synthetic database error, a test spy, and a fixed local test relation. Added lines contain n…
Engage In Review Feedback ✅ Passed PASS: The supplied review metadata reports no CodeRabbit review threads and zero actionable findings. No review feedback comment required engagement, implementation, or reviewer retraction.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.95%. Comparing base (6145e7f) to head (ebd6474).

Additional details and impacted files
@@            Coverage Diff             @@
##            alpha   #10727      +/-   ##
==========================================
+ Coverage   93.93%   93.95%   +0.01%     
==========================================
  Files         193      193              
  Lines       17071    17071              
  Branches      257      257              
==========================================
+ Hits        16036    16039       +3     
+ Misses       1013     1010       -3     
  Partials       22       22              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mtrezza
mtrezza merged commit ca91c7f into parse-community:alpha Sep 29, 2026
25 checks passed
@mtrezza
mtrezza deleted the test/update-error-coverage branch September 29, 2026 19:27
@parseplatformorg

Copy link
Copy Markdown
Contributor

🎉 This change has been released in version 9.10.2-alpha.6

@parseplatformorg parseplatformorg added the state:released-alpha Released as alpha version label Sep 30, 2026
@parseplatformorg

Copy link
Copy Markdown
Contributor

🎉 This change has been released in version 9.10.2

@parseplatformorg parseplatformorg added the state:released Released as stable version label Oct 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

state:released Released as stable version state:released-alpha Released as alpha version

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Decide whether codecov/project should report on PRs

2 participants