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

Firestore: Fix "missing index" error message #6712

Merged
merged 15 commits into from
Oct 27, 2022

Conversation

milaGGL
Copy link
Contributor

@milaGGL milaGGL commented Oct 20, 2022

Fix a bug where missing index error message is not displayed as expected.

Expected error message

It should display "The query requires an index. Please create it here: http://.....". By clicking the link, user will be directed to console where they can create the required index.

Current error message:

  • Full SDK: "Server responded with status 400"
  • Lite SDK:"Bad request"

Cause

when server respond to the request with missing index, error object is wrapped inside an array. By trying to read the error message field directly from the array, it always fails and get "undefined".
So, extract the error object from the array before reading the error message field.

Fixes #6613

@changeset-bot
Copy link

changeset-bot bot commented Oct 20, 2022

🦋 Changeset detected

Latest commit: d4012d9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@firebase/firestore Patch
firebase Patch
@firebase/firestore-compat Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Oct 21, 2022

Size Report 1

Affected Products

  • @firebase/firestore

    TypeBase (941ad29)Merge (089aa6c)Diff
    browser266 kB266 kB+84 B (+0.0%)
    esm5330 kB330 kB+84 B (+0.0%)
    main531 kB531 kB+11 B (+0.0%)
    module266 kB266 kB+84 B (+0.0%)
    react-native266 kB266 kB+84 B (+0.0%)
  • @firebase/firestore-lite

    TypeBase (941ad29)Merge (089aa6c)Diff
    browser82.3 kB82.4 kB+138 B (+0.2%)
    esm598.5 kB98.6 kB+157 B (+0.2%)
    main139 kB139 kB+303 B (+0.2%)
    module82.3 kB82.4 kB+138 B (+0.2%)
    react-native82.4 kB82.6 kB+138 B (+0.2%)
  • @firebase/messaging

    TypeBase (941ad29)Merge (089aa6c)Diff
    browser21.3 kB21.4 kB+94 B (+0.4%)
    esm526.7 kB26.8 kB+92 B (+0.3%)
    main27.4 kB27.5 kB+92 B (+0.3%)
    module21.3 kB21.4 kB+94 B (+0.4%)
  • @firebase/messaging-sw

    TypeBase (941ad29)Merge (089aa6c)Diff
    main30.1 kB30.2 kB+92 B (+0.3%)
    module23.3 kB23.4 kB+94 B (+0.4%)
  • @firebase/performance

    TypeBase (941ad29)Merge (089aa6c)Diff
    browser29.1 kB29.1 kB+40 B (+0.1%)
    esm530.8 kB30.8 kB+40 B (+0.1%)
    main31.2 kB31.3 kB+40 B (+0.1%)
    module29.1 kB29.1 kB+40 B (+0.1%)
  • bundle

    14 size changes

    TypeBase (941ad29)Merge (089aa6c)Diff
    firestore (Persistence)276 kB276 kB+73 B (+0.0%)
    firestore (Query Cursors)213 kB213 kB+84 B (+0.0%)
    firestore (Query)214 kB214 kB+84 B (+0.0%)
    firestore (Read data once)202 kB202 kB+84 B (+0.0%)
    firestore (Realtime updates)205 kB205 kB+84 B (+0.0%)
    firestore (Transaction)186 kB186 kB+73 B (+0.0%)
    firestore (Write data)186 kB186 kB+73 B (+0.0%)
    firestore-lite (Query Cursors)71.4 kB71.5 kB+138 B (+0.2%)
    firestore-lite (Query)74.6 kB74.7 kB+138 B (+0.2%)
    firestore-lite (Read data once)59.0 kB59.1 kB+138 B (+0.2%)
    firestore-lite (Transaction)83.6 kB83.7 kB+138 B (+0.2%)
    firestore-lite (Write data)68.7 kB68.9 kB+138 B (+0.2%)
    messaging (send + receive)46.3 kB46.4 kB+58 B (+0.1%)
    performance (trace)50.8 kB50.8 kB+24 B (+0.0%)

  • firebase

    11 size changes

    TypeBase (941ad29)Merge (089aa6c)Diff
    firebase-compat.js740 kB740 kB+196 B (+0.0%)
    firebase-firestore-compat.js313 kB314 kB+92 B (+0.0%)
    firebase-firestore-lite.js89.0 kB89.1 kB+138 B (+0.2%)
    firebase-firestore.js314 kB314 kB+84 B (+0.0%)
    firebase-messaging-compat.js38.2 kB38.3 kB+98 B (+0.3%)
    firebase-messaging-sw.js26.0 kB26.0 kB+55 B (+0.2%)
    firebase-messaging.js24.8 kB24.9 kB+55 B (+0.2%)
    firebase-performance-compat.js30.7 kB30.7 kB+6 B (+0.0%)
    firebase-performance-standalone-compat.es2017.js90.0 kB90.0 kB+13 B (+0.0%)
    firebase-performance-standalone-compat.js66.5 kB66.5 kB+6 B (+0.0%)
    firebase-performance.js30.7 kB30.7 kB+13 B (+0.0%)

Test Logs

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/QdqHjkrWW2.html

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Oct 21, 2022

Size Analysis Report 1

Affected Products

  • @firebase/firestore

    • addDoc

      Size

      TypeBase (941ad29)Merge (089aa6c)Diff
      size116 kB116 kB+73 B (+0.1%)
      size-with-ext-deps176 kB176 kB+73 B (+0.0%)
    • deleteDoc

      Size

      TypeBase (941ad29)Merge (089aa6c)Diff
      size107 kB107 kB+73 B (+0.1%)
      size-with-ext-deps167 kB167 kB+73 B (+0.0%)
    • disableNetwork

      Size

      TypeBase (941ad29)Merge (089aa6c)Diff
      size95.7 kB95.8 kB+73 B (+0.1%)
      size-with-ext-deps155 kB155 kB+73 B (+0.0%)
    • enableIndexedDbPersistence

      Size

      TypeBase (941ad29)Merge (089aa6c)Diff
      size174 kB174 kB+73 B (+0.0%)
      size-with-ext-deps234 kB234 kB+73 B (+0.0%)
    • enableMultiTabIndexedDbPersistence

      Size

      TypeBase (941ad29)Merge (089aa6c)Diff
      size207 kB207 kB+73 B (+0.0%)
      size-with-ext-deps267 kB267 kB+73 B (+0.0%)
    • enableNetwork

      Size

      TypeBase (941ad29)Merge (089aa6c)Diff
      size95.7 kB95.8 kB+73 B (+0.1%)
      size-with-ext-deps155 kB155 kB+73 B (+0.0%)
    • executeWrite

      Size

      TypeBase (941ad29)Merge (089aa6c)Diff
      size106 kB106 kB+73 B (+0.1%)
      size-with-ext-deps166 kB166 kB+73 B (+0.0%)
    • getCountFromServer

      Size

      TypeBase (941ad29)Merge (089aa6c)Diff
      size102 kB102 kB+73 B (+0.1%)
      size-with-ext-deps162 kB162 kB+73 B (+0.0%)
    • getDoc

      Size

      TypeBase (941ad29)Merge (089aa6c)Diff
      size133 kB133 kB+84 B (+0.1%)
      size-with-ext-deps192 kB192 kB+84 B (+0.0%)
    • getDocFromServer

      Size

      TypeBase (941ad29)Merge (089aa6c)Diff
      size133 kB133 kB+84 B (+0.1%)
      size-with-ext-deps192 kB192 kB+84 B (+0.0%)
    • getDocs

      Size

      TypeBase (941ad29)Merge (089aa6c)Diff
      size134 kB134 kB+84 B (+0.1%)
      size-with-ext-deps194 kB194 kB+84 B (+0.0%)
    • getDocsFromServer

      Size

      TypeBase (941ad29)Merge (089aa6c)Diff
      size134 kB134 kB+84 B (+0.1%)
      size-with-ext-deps194 kB194 kB+84 B (+0.0%)
    • loadBundle

      Size

      TypeBase (941ad29)Merge (089aa6c)Diff
      size105 kB105 kB+73 B (+0.1%)
      size-with-ext-deps164 kB164 kB+73 B (+0.0%)
    • onSnapshot

      Size

      TypeBase (941ad29)Merge (089aa6c)Diff
      size135 kB135 kB+84 B (+0.1%)
      size-with-ext-deps194 kB194 kB+84 B (+0.0%)
    • onSnapshotsInSync

      Size

      TypeBase (941ad29)Merge (089aa6c)Diff
      size124 kB125 kB+84 B (+0.1%)
      size-with-ext-deps184 kB184 kB+84 B (+0.0%)
    • runTransaction

      Size

      TypeBase (941ad29)Merge (089aa6c)Diff
      size116 kB116 kB+73 B (+0.1%)
      size-with-ext-deps176 kB176 kB+73 B (+0.0%)
    • setDoc

      Size

      TypeBase (941ad29)Merge (089aa6c)Diff
      size115 kB115 kB+73 B (+0.1%)
      size-with-ext-deps175 kB175 kB+73 B (+0.0%)
    • updateDoc

      Size

      TypeBase (941ad29)Merge (089aa6c)Diff
      size116 kB116 kB+73 B (+0.1%)
      size-with-ext-deps175 kB175 kB+73 B (+0.0%)
    • waitForPendingWrites

      Size

      TypeBase (941ad29)Merge (089aa6c)Diff
      size96.1 kB96.2 kB+73 B (+0.1%)
      size-with-ext-deps156 kB156 kB+73 B (+0.0%)
    • writeBatch

      Size

      TypeBase (941ad29)Merge (089aa6c)Diff
      size118 kB118 kB+73 B (+0.1%)
      size-with-ext-deps177 kB177 kB+73 B (+0.0%)
  • @firebase/messaging

    • deleteToken

      Size

      TypeBase (941ad29)Merge (089aa6c)Diff
      size12.7 kB12.8 kB+58 B (+0.5%)
      size-with-ext-deps38.5 kB38.5 kB+58 B (+0.2%)
    • getMessaging

      Size

      TypeBase (941ad29)Merge (089aa6c)Diff
      size13.2 kB13.2 kB+58 B (+0.4%)
      size-with-ext-deps46.0 kB46.1 kB+58 B (+0.1%)
    • getToken

      Size

      TypeBase (941ad29)Merge (089aa6c)Diff
      size12.6 kB12.7 kB+58 B (+0.5%)
      size-with-ext-deps38.3 kB38.4 kB+58 B (+0.2%)
    • isSupported

      Size

      TypeBase (941ad29)Merge (089aa6c)Diff
      size13.0 kB13.0 kB+58 B (+0.4%)
      size-with-ext-deps38.6 kB38.7 kB+58 B (+0.2%)
    • onMessage

      Size

      TypeBase (941ad29)Merge (089aa6c)Diff
      size12.7 kB12.8 kB+58 B (+0.5%)
      size-with-ext-deps38.5 kB38.5 kB+58 B (+0.2%)
  • @firebase/performance

    • getPerformance

      Size

      TypeBase (941ad29)Merge (089aa6c)Diff
      size18.0 kB18.0 kB+24 B (+0.1%)
      size-with-ext-deps50.7 kB50.7 kB+24 B (+0.0%)
    • initializePerformance

      Size

      TypeBase (941ad29)Merge (089aa6c)Diff
      size18.2 kB18.2 kB+24 B (+0.1%)
      size-with-ext-deps44.1 kB44.1 kB+24 B (+0.1%)
    • trace

      Size

      TypeBase (941ad29)Merge (089aa6c)Diff
      size17.9 kB17.9 kB+24 B (+0.1%)
      size-with-ext-deps43.5 kB43.5 kB+24 B (+0.1%)

Test Logs

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/iO7ZRxfoEp.html

@milaGGL milaGGL changed the title Dconeybe/count missing index test Fix missing index error message in Firestore Lite Oct 21, 2022
Copy link
Contributor

@dconeybe dconeybe left a comment

Choose a reason for hiding this comment

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

This fix looks perfect to me. Nice work! Just a few minor comments.

@milaGGL milaGGL marked this pull request as ready for review October 24, 2022 21:16
@milaGGL milaGGL requested a review from dconeybe October 24, 2022 21:22
@dconeybe dconeybe changed the title Fix missing index error message in Firestore Lite Firestore: Fix "missing index" error message Oct 26, 2022
Copy link
Contributor

@dconeybe dconeybe left a comment

Choose a reason for hiding this comment

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

Add a changeset please.

Great work! What an elegant fix.

Copy link
Contributor

@dconeybe dconeybe left a comment

Choose a reason for hiding this comment

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

Just one tiny change to the changelog entry. Otherwise LGTM.

.changeset/little-rats-relax.md Outdated Show resolved Hide resolved
@milaGGL milaGGL merged commit bf7cc8f into master Oct 27, 2022
@milaGGL milaGGL deleted the dconeybe/CountMissingIndexTest branch October 27, 2022 00:58
@google-oss-bot google-oss-bot mentioned this pull request Nov 8, 2022
@firebase firebase locked and limited conversation to collaborators Nov 26, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Uncaught Error in snapshot listener: {"code":"failed-precondition","name":"FirebaseError"}
3 participants