Node.js fetch upsert stopped working without me changing anything

Has something changed about the upsert API? I have been using node fetch via this module:

The module hasn’t changed, and my code hasn’t changed, but the upsert stopped working and started returning this error:

HTTPError: Request failed with status code 400 Bad Request

I checked that my requests are still valid, dimensions matches index, env variables are still correct.

Has the API changed? I checked documentation, but really struggling to figure out what is going wrong.

I tried using node fetch directly by following the API documentation here and got this response:

Response {
size: 0,
timeout: 0,
[Symbol(Body internals)]: {
body: PassThrough {
_readableState: [ReadableState],
_events: [Object: null prototype],
_eventsCount: 2,
_maxListeners: undefined,
_writableState: [WritableState],
allowHalfOpen: true,
[Symbol(kCapture)]: false,
[Symbol(kCallback)]: null
},
disturbed: false,
error: null
},
[Symbol(Response internals)]: {
url: ‘https://pg1-81ce579.svc.us-west1-gcp.pinecone.io/vectors/upsert’,
status: 400,
statusText: ‘Bad Request’,
headers: Headers { [Symbol(map)]: [Object: null prototype] },
counter: 0
}
}

Hi @shore ,

This client is an unofficial client, which we don’t support. We will be releasing our official JS/TS Pinecone Client soon, and we’ll be able to guide you on how to migrate to it. In the mean time, could you share your fetch request so I could see what may be wrong with it?

Roie

const fetch = require(“node-fetch”);

const options = {
method: “POST”,
headers: {
“accept”: “application/json”,
“content-type”: “application/json”,
“Api-Key”: process.env.PINECONE_API_KEY,
},
body: {
vectors: vectors,
namespace: nameSpace,
},
};

fetch(process.env.PINECONE_BASE_URL + “/vectors/upsert”, options)
.then((res) => console.log(res))
.catch((err) => console.error(“error:” + err));


vectors is an array of vectors with 1536 dimensions (same as the index). nameSpace is a string of a URL (has a period in it).

Here is the vectors json array:

[
{
id: ‘831a2f56-393f-4dcb-8a07-912945975f66-bdd282f4-58ce-4fec-836c-2889779be1fd’,
values: [
-0.020409154, -0.011643771, 0.0065894565, -0.036240295,
-0.0018743799, 0.0169825, -0.022012828, 0.005828739,
0.004975502, -0.014200056, -0.011965877, 0.013590111,
0.0030839888, 0.007792212, -0.0123839285, -0.012671768,
0.02127267, 0.0026539438, -0.004262758, -0.017613003,
-0.02253368, 0.01029367, -0.009868764, -0.023589088,
-0.015954502, -0.0025117376, 0.0026265306, -0.029386988,
-0.0012687187, 0.00054312474, 0.007792212, -0.029524054,
-0.002597404, -0.01027311, -0.029386988, -0.00472193,
0.024713032, 0.01872324, 0.010773401, 0.01288422,
0.039173514, -0.0070794676, -0.005283901, -0.0018075602,
-0.0013860817, 0.037419066, -0.014515308, -0.0030908422,
-0.022314373, 0.0066956826, -0.0037556132, -0.00066862593,
-0.021176724, 0.0051125684, 0.0076071727, 0.011074947,
0.01288422, 0.020834059, -0.010197723, -0.05523767,
0.009820791, -0.020888885, -0.026385238, 0.014762027,
-0.0015728343, -0.01758559, -0.0111434795, 0.022053948,
-0.0027053435, -0.011732864, 0.034211718, -0.0011496425,
0.004043452, 0.005273621, 0.03136074, -0.01690026,
-0.014885386, -0.005085155, 0.006860162, 0.019792356,
0.009711138, -0.009018954, -0.025658788, 0.044436853,
0.01300758, 0.010163457, 0.010307376, 0.0031559486,
-0.008443276, -0.022944877, -0.0030308757, 0.015433651,
0.005431247, 0.0039680656, 0.016365701, 0.004896689,
-0.005420967, 0.020244675, -0.008929861, -0.0038515595,
… 1436 more items
],
metadata: {
personElementId: ‘bdd282f4-58ce-4fec-836c-2889779be1fd’,
type: ‘P’
}
},
{
id: ‘e8bbe53f-0a32-4d5b-979f-987b5e730a34-bdd282f4-58ce-4fec-836c-2889779be1fd’,
values: [
-0.007907896, -0.010311679, 0.008502013, -0.01819226,
-0.008870775, 0.019544387, -0.016894763, -0.00046991548,
0.01145211, -0.013575905, -0.0026376727, 0.003457144,
0.0018591752, 0.017482052, 0.003318858, 0.0001734974,
0.038679037, 0.0013965154, 0.011103834, -0.0012035982,
-0.0072864643, 0.004968044, -0.0040597967, -0.025895288,
-0.018397126, -0.0005885681, 0.028517596, -0.025977235,
0.0049065836, -0.011875503, 0.03668499, -0.021319907,
-0.0062040794, 0.0039198035, -0.028135177, 0.011684293,
0.027315704, 0.020145332, 0.0024208543, -0.017318157,
0.044770442, 0.012155489, -0.001617602, -0.006333829,
0.010496059, 0.016457712, -0.01939415, 0.010946768,
-0.04332271, 0.007969357, 0.005374365, 0.0133573795,
-0.021675011, -0.00052198605, -0.0053709503, -0.0016500393,
0.011219926, 0.014067588, 0.001592847, -0.03433584,
-0.00070167216, -0.008939064, -0.01939415, 0.021415513,
-0.008952722, -0.011056031, 0.006282612, 0.007211346,
0.0025010942, 0.00047290314, 0.012756434, 0.014682191,
0.01800105, 0.0010431185, 0.02269935, 0.002190378,
-0.0012590833, -0.007839607, 0.015597267, 0.0027896164,
0.013118368, -0.0102229025, -0.025717735, 0.030538958,
0.0049578003, -0.014258798, 0.011281386, 0.007245491,
0.0026888896, -0.024829976, 0.00324374, 0.008980038,
0.005801173, 0.012305725, -0.014354403, 0.010209245,
0.012490106, 0.017960075, -0.005476799, -0.016771844,
… 1436 more items
],
metadata: {
personElementId: ‘bdd282f4-58ce-4fec-836c-2889779be1fd’,
type: ‘F’
}
},
{
id: ‘aec13e71-fcaf-493e-81a4-5f56045b31a1-bdd282f4-58ce-4fec-836c-2889779be1fd’,
values: [
-0.013771316, -0.007757521, 0.0057460573, -0.011547036,
0.009350215, 0.019483048, -0.0042666364, -0.0026842395,
0.028970564, -0.030316116, 0.008128234, -0.0028455686,
0.015789645, 0.011704932, 0.010125968, -0.003971439,
0.02302542, -0.008924581, 0.010290729, -0.021583756,
-0.018027654, 0.03182643, -0.025716525, -0.0049634404,
-0.02640303, -0.021377806, 0.010606522, -0.027638743,
-0.0078124413, 0.0043833423, 0.029327547, -0.041053075,
-0.015720993, -0.02636184, -0.020979632, 0.0029073542,
0.02305288, 0.0036659434, -0.0043387194, -0.02501629,
0.025908746, -0.0043764776, -0.0039439783, -0.026787475,
0.0097621195, 0.03064564, 0.010029857, 0.023753118,
-0.04275561, 0.01421068, 0.015899485, -0.008368512,
-0.0011653444, -0.010421165, -0.004410803, 0.004249474,
-0.002790648, 0.024412163, 0.005155662, -0.045281954,
-0.01147152, -0.015199249, -0.007331887, 0.029162787,
0.0015206113, 0.002093844, -0.011402869, 0.011883424,
-0.011540171, -0.01853567, 0.0071671256, 0.014004728,
0.014938377, -0.014581393, 0.026952237, -0.014334251,
-0.0014167773, -0.008903986, 0.01981257, 0.016311388,
0.023094071, -0.001557511, -0.027995726, 0.0348196,
0.0072563714, 0.005715165, 0.021377806, 0.029464848,
0.0032197144, -0.011643146, 0.011327353, 0.007984068,
0.007215181, 0.0007607348, -0.0074005374, 0.0136752045,
0.012343382, 0.03416055, -0.00040932937, 0.0076476797,
… 1436 more items
],
metadata: {
personElementId: ‘bdd282f4-58ce-4fec-836c-2889779be1fd’,
type: ‘F’
}
},
{
id: ‘b247e025-f428-48fd-9eb2-01f0c98c660d-bdd282f4-58ce-4fec-836c-2889779be1fd’,
values: [
-0.00032378043, -0.003181799, 0.0007460076, -0.028338663,
-0.018817768, 0.028296659, -0.01010895, 0.015163424,
0.0027635098, 0.0004263838, -0.0035195807, -0.0021667036,
0.005253994, 0.018971782, 0.013210242, -0.0055340203,
0.037719544, -0.0067311325, 0.016031506, -0.008547803,
-0.025454393, 0.016311532, -0.0026987535, -0.026112454,
-0.023900246, -0.01010895, 0.013644282, -0.03564735,
-0.00042922783, -0.0118521135, 0.008925838, -0.024306284,
0.010136953, -0.013028224, -0.026294472, -0.014085324,
0.01946183, 0.002490484, -0.000074108524, 0.0072946856,
0.045588285, -0.0009424636, 0.0003767229, -0.009002846,
-0.0045259255, 0.038979664, -0.008323782, -0.0063075926,
-0.027806614, 0.011502081, 0.027638597, -0.0010999783,
-0.02850668, 0.0050859777, 0.008281779, -0.00038131708,
0.0015935247, 0.007364692, 0.021464016, -0.036039386,
-0.014274341, -0.0041233874, -0.023116171, 0.028184649,
0.010045944, 0.002308467, 0.002191206, 0.016101513,
-0.013000222, -0.02245811, 0.024460299, 0.001991687,
0.00807876, 0.00489696, 0.03203501, -0.008421792,
-0.0244743, 0.008155766, 0.019251809, 0.012377163,
0.015135422, -0.013952311, -0.010570994, 0.026140457,
0.0046624383, -0.0052329917, 0.0003716912, 0.009093855,
-0.0045294254, -0.03382718, 0.015947498, -0.0015672722,
0.0031047917, -0.006003064, 0.015513457, 0.006342596,
-0.0016136516, 0.00968891, -0.019545836, -0.026672507,
… 1436 more items
],
metadata: {
personElementId: ‘bdd282f4-58ce-4fec-836c-2889779be1fd’,
type: ‘P’
}
},
{
id: ‘f7d2163a-cab3-4d61-a8f9-9af557d572ab-bdd282f4-58ce-4fec-836c-2889779be1fd’,
values: [
-0.018607482, -0.0009889469, 0.015130464, -0.022111665,
-0.0022036964, 0.014247627, -0.011266355, -0.007979486,
0.017181361, -0.022233903, 0.0020305244, -0.0012936954,
-0.0024481742, 0.020210171, -0.012488744, 0.008094934,
0.027327193, -0.003258007, 0.015347777, -0.015728077,
-0.026050474, 0.019449573, -0.017874049, 0.0057486254,
-0.039306607, -0.02196226, 0.025154056, -0.0324069,
-0.018553155, 0.006111947, 0.031103017, -0.03183645,
-0.01498106, -0.019761961, -0.026131967, -0.007918366,
0.029283015, 0.015021807, 0.01931375, -0.012026953,
0.03118451, 0.00545661, -0.0051781773, -0.025805997,
-0.0059897075, 0.017154196, 0.013520984, 0.007069485,
-0.016054047, 0.011565161, 0.017575242, 0.013921657,
-0.009745159, 0.0019643118, 0.0033208244, -0.0026536034,
-0.0038199667, 0.018634647, -0.000100168014, -0.044386316,
0.0048827664, -0.0025941818, -0.017534496, 0.033276156,
-0.004886162, 0.005402282, 0.0005008401, 0.012481953,
-0.00910001, -0.02227465, 0.02394525, 0.015130464,
0.016284943, -0.0058708643, 0.014899568, -0.0076263514,
-0.0007368291, -0.022736441, 0.0004312318, 0.011028668,
0.017548079, -0.0061560883, -0.020196589, 0.019598976,
0.0105125485, 0.0078029186, 0.0068419846, 0.010363145,
0.0043157134, -0.017249271, -0.007775754, 0.009161129,
-0.0032138652, 0.0068148207, -0.01084531, 0.013650014,
0.020576887, 0.03183645, 0.0023463084, -0.018512407,
… 1436 more items
],
metadata: {
personElementId: ‘bdd282f4-58ce-4fec-836c-2889779be1fd’,
type: ‘F’
}
}
]

Hi @shore ,

You’re trying to fetch but calling the upserts endpoint. The fetch endpoint is /vectors/fetch.

You can consider this issue resolved. I am not sure how to close this thread…

with await response.text() I was able to get to this error:

invalid value Starting an object on a scalar field for type namespace

Which clued me into a schema change that I wasn’t aware of.

Thanks for your attention. Really looking forward to the officially supported node.js module when its ready.

1 Like