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

startAfter and endBefore throw with no key argument when using REST #8487

Open
tonyhallett opened this issue Sep 7, 2024 · 3 comments
Open

Comments

@tonyhallett
Copy link

Operating System

Windows 11

Environment (if applicable)

Version 128.0.6613.115 (Official Build) (64-bit)

Firebase SDK Version

^10.12.2

Firebase SDK Product(s)

Database

Project Tooling

React, typescript with Parcel

Detailed Problem Description

use constrainsts startAfter and endBefore without keys using REST.

"{ "error" : "Constraint key field must be a valid key name" } "

Due to the placeholders MAX_NAME and MIN_NAME being included in the generated url.
startAfter(2)
"http://127.0.0.1:9000/things.json?ns=mydb-default-rtdb&orderBy=%22pNumber%22&startAfter=2%2C%22%5BMAX_NAME%5D%22&format=export"

endBefore(2)
http://127.0.0.1:9000/things.json?ns=mydb-default-rtdb&orderBy=%22pNumber%22&endBefore=2%2C%22%5BMIN_NAME%5D%22&format=export

See

params = queryParamsStartAt(queryParams, indexValue, MAX_NAME);

params = queryParamsEndAt(queryParams, indexValue, MIN_NAME);

If being crawled will use REST

if (repo.forceRestClient_ || beingCrawled()) {

Steps and code to reproduce issue

//Links in problem description should suffice

@tonyhallett tonyhallett added new A new issue that hasn't be categoirzed as question, bug or feature request question labels Sep 7, 2024
@google-oss-bot
Copy link
Contributor

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

@tonyhallett tonyhallett changed the title Title for the bug startAfter and endBefore throw with no key argument when using REST Sep 7, 2024
@jbalidiong jbalidiong added api: database needs-attention and removed needs-triage new A new issue that hasn't be categoirzed as question, bug or feature request labels Sep 9, 2024
@dlarocque
Copy link
Contributor

Hi @tonyhallett, I don't fully understand the issue. Please share more information including

  • What you're trying to do
  • What the expected behaviour is
  • What the real behaviour is
  • Code snippets to help us reproduce the issue

@tonyhallett
Copy link
Author

What you're trying to do
Use startAt or endBefore in a query

What the expected behaviour is
It works when the js sdk uses REST due to being crawled ( or have manually created a Repo that forces REST ).

What the real behaviour is
"{ "error" : "Constraint key field must be a valid key name" } "

Code snippets to help us reproduce the issue
Given a list of things where a Thing has a field pNumber
onValue(query(ref(db,"things"), orderByChild("pNumber"), startAt(2)), (snapshot) => { });

To see the error you will need to add a break point in the constructor for the Repo class and set the forceRestClient to true.

  constructor(
    public repoInfo_: RepoInfo,
    public forceRestClient_: boolean,
    public authTokenProvider_: AuthTokenProvider,
    public appCheckProvider_: AppCheckTokenProvider
  ) {
    // This key is intentionally not updated if RepoInfo is later changed or replaced
    this.key = this.repoInfo_.toURLString();
  }

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

No branches or pull requests

4 participants