Skip to content

fix: handle excessively long URLs by performing local equality checks. ref #7986#8432

Open
len360 wants to merge 2 commits intopubkey:masterfrom
len360:bugfix/issue-7986
Open

fix: handle excessively long URLs by performing local equality checks. ref #7986#8432
len360 wants to merge 2 commits intopubkey:masterfrom
len360:bugfix/issue-7986

Conversation

@len360
Copy link
Copy Markdown

@len360 len360 commented Apr 27, 2026

This PR contains:

  • A bug fix
  • Improved tests

Describe the problem you have without this PR

Without this fix, large payloads were being included in the URL, causing bad request errors. This issue is related to supabase/postgrest-js#393.

Pull Request Description

This PR contains a bug fix corresponding to issue #7986. It removes the inclusion of all parameters in the URL in order to perform a local comparison of objects instead of making long requests that cause bad request errors.

Logic implemented

On update events:

  1. Fetch the selected document from the server
  2. Compare the assumed master state with the server state locally
  3. If a difference is detected, a conflict is detected and the current server state is returned
  4. Otherwise, the server state is updated

Unit tests

A unit test has been added to verify that updating a property with a large number of characters does not cause any errors, ensuring that this pull request properly resolves the issue.

len360 added 2 commits April 27, 2026 15:35
On patch event:
1. Fetch the selected document from the server
2. Compare the assumed master state with the server state locally
3. If there is a difference -> conflict detected, return the server state
4. Otherwise -> update the server state
@len360
Copy link
Copy Markdown
Author

len360 commented Apr 28, 2026

Hi @pubkey, I'm embarrassed because the issue detected in CI / test-others-replications (pull_request) can't be reproduced on my computer and seems to appear in multiple GitHub Actions (#44804).

Another thing is that the issue in Verify Test Reproduction / test-without-fix (pull_request) mentions a missing issue. This PR is related to issue #7986. Did I miss something to indicate the link between the PR and the ticket, or does it need to be reopened?

query
);
// fetch the current document state from the server
const docOnServer: WithDeleted<RxDocType> = await fetchById(id);
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

By fetching here first it is not inside of one transaction anymore. What happens if someone else changes the document on the server after we fetch docOnServer and before sending the new one to the server?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

In fact, this implementation seems problematic. If someone modifies the data in the database while another user is fetching it, the last user to write will overwrite the previous changes without any conflict handling.

Another way to address the issue of overly long URLs would be to add a hash property to the object. This "hash" could be included in the URL alongside the identifier, allowing the update to be performed in a single transaction while also helping detect potential conflicts.

What do you think about this approach?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants