-
Notifications
You must be signed in to change notification settings - Fork 38
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
Overhaul error handling to prevent unrelated text() error from masking underlying exceptions #135
Conversation
204670e
to
316adc1
Compare
316adc1
to
808366c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fantastic work, really appreciate this cleanup. I found it's much easier overall to reason about how errors are flowing through things now as opposed to before. I also really appreciate adding in additional integration tests while you're here.
Just a few questions, but overall looks good to me. Having error handling and throwing centralized rather than all over the place feels good. 🚢
@@ -8,13 +9,56 @@ import { BasePineconeError } from './base'; | |||
* - Incorrect configuration of the client. The client builds its connection url using values supplied in configuration, so if these values are incorrect the request will not reach a Pinecone server. | |||
* - An outage of Pinecone's APIs. See [Pinecone's status page](https://status.pinecone.io/) to find out whether there is an ongoing incident. | |||
* | |||
* The `cause` property will contain a reference to the underlying error. Inspect its value to find out more about the root cause of the error. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
praise: Thank you for the docstring date. 👍
|
||
export const middleware = [ | ||
{ | ||
onError: async (context) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
praise: Huge praise for all this cleanup, I feel like errors are much more straightforward to reason around now, and it's really helpful to pull all the testing into a more centralized place rather than having it spread across all the individual methods.
src/utils/testHelper.ts
Outdated
@@ -0,0 +1,11 @@ | |||
import { ResponseError } from '../pinecone-generated-ts-fetch'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: Can this file be removed? Doesn't seem like it's actually being used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I think it can be removed. I had created a new test-helper in here but later I ended up deleting all the unit tests that were using it. 😂
beforeEach(async () => { | ||
pinecone = new Pinecone(); | ||
indexName = randomIndexName('configureIndex'); | ||
|
||
await pinecone.createIndex({ | ||
name: indexName, | ||
dimension: 5, | ||
waitUntilReady: true, | ||
podType: 'p1.x1', | ||
replicas: 2, | ||
}); | ||
}); | ||
|
||
afterEach(async () => { | ||
await pinecone.deleteIndex(indexName); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: Do we need to be creating and deleting an index for each test rather than using beforeAll
and afterAll
? It seems like this would lead to slower tests as we have to wait somewhere around 10 seconds for each index to spin up for each test. For this specific suite could we not just create an index once, perform all the tests and operations, and then delete afterAll
for cleanup?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As currently written, this test suite does end up adding quite a bit of time due to the index creation. But for now I want to keep every test fully isolated from others.
There seems to be some timing issues in this configure endpoint when called multiple times at a row. At one point I had a test here that scaled replicas up and then down again (using the same index) and it was throwing a 500 error at a high rate, even when I waited for status to reach the Ready state. I don't think they envisioned people scaling up and down separated only by milliseconds.
|
||
test('calling data plane', async () => { | ||
const p = new Pinecone({ | ||
apiKey: 'api-key-2', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: Should this still be process.env.PINECONE_API_KEY
? Asking as the section is described as when environment is wrong
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can change it to make it more clear that the environment is the only thing that matters here. Ultimately only the environment
value matters for this test since it's an input into the url and there is no wrong-environment
environment in production.
Problem
Some users are still running into errors that can't be properly diagnosed because of a bug in error handling causing the real error to get obscured by an unrelated problem. There's a point at which we assume we should be dealing with a
ResponseError
with atext()
field; in reality, that's not a correct assumption so it's not safe to cast to that type.Solution
This was one of those changes where you pull on the thread and the whole carpet unravels.
cause
whenever aPineconeConnectionError
exception is being thrown. This will help us investigate [Bug] v1 Index<T>.query throwing TypeError: Cannot read properties of undefined (reading 'text') during migration #124PINECONE_DEBUG
request middleware #136.Summary of files changed:
src/errors/handling.ts
:text()
property.PineconeConnectionError
src/errors
:PineconeConnectionError
andBasePineconeError
modified to allow reference to underlying errors to be captured.PineconeConnectionError
might occur.handleApiError
src/pinecone.ts
andsrc/data/index.ts
. Now we can be confident we are handling errors consistently across every method without the need for a lot of repetitive unit testing to verify wiring on each client method.Type of Change
Test Plan
Describe specific steps for validating this change.