-
Notifications
You must be signed in to change notification settings - Fork 64
Description
Hello,
I'm trying to create paginated API endpoint with oracle noSQL database and ran into the error related to page
param. I believe it's a bug.
Let's say we have 4 Elements in our table. Following code makes 5 requests. 1-4 requests return opcNextPage
which is fine. (Of course 4th could early return null already since there will not be any more items in next response). 5th (Last one) request fails with error Error: QUERY: Illegal Argument: Invalid page: Illegal base64 character 20
.
Following code produces this error:
const ociNoSql = require('oci-nosql');
const ociCommon = require('oci-common');
const oracleNoSqlFalconDefaults = {
name: 'YOUR_TABLE_NAME',
compartmentId: 'YOUR_COMPARTMENT_ID',
};
const configurationFilePath = '~/.oci/config'; // Or your path
const provider = new ociCommon.ConfigFileAuthenticationDetailsProvider(
configurationFilePath,
);
const oracleNoSqlClient = new ociNoSql.NosqlClient({ authenticationDetailsProvider: provider });
async function paginate() {
let pageString;
do {
const queryResult = await oracleNoSqlClient.query({
queryDetails: {
compartmentId: oracleNoSqlFalconDefaults.compartmentId,
statement: `SELECT * FROM ${oracleNoSqlFalconDefaults.name}`,
},
limit: 1,
page: pageString,
});
pageString = queryResult.opcNextPage;
} while (pageString);
}
async function main() {
try {
await paginate();
} catch (error) {
console.error(error);
}
}
main();
This error is specific for this SDK. Since I've used oci
tool on macOS ARM (oci --version
is 3.23.4
).
oci nosql query execute --compartment-id $compartmentId --statement "SELECT * FROM $table" --limit 1 --page $page
Such command on last result (same arguments are used) returns normal response:
{
"data": {
"items": [],
"usage": {
"read-units-consumed": 2,
"write-units-consumed": 0
}
}
}
oci npm versions from my package.json
:
"oci-common": "^2.55.0",
"oci-nosql": "^2.55.0",