diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b0b87397..8d2ddbea 100755 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -52,7 +52,7 @@ jobs: - run: psql test -c 'alter database test set enable_seqscan = off' # setup the database for testing - - run: make installcheck REGRESS="pinecone_crud pinecone_medium_create pinecone_zero_vector_insert pinecone_build_after_insert pinecone_index_metrics" REGRESS_OPTS="--dbname=test --inputdir=./test --use-existing" + - run: make installcheck REGRESS="pinecone_crud pinecone_medium_create pinecone_zero_vector_insert pinecone_build_after_insert pinecone_invalid_config pinecone_index_metrics" REGRESS_OPTS="--dbname=test --inputdir=./test --use-existing" - if: ${{ failure() }} run: cat regression.diffs # mac: diff --git a/src/pinecone/pinecone_validate.c b/src/pinecone/pinecone_validate.c index 3bfbe961..93cfb790 100644 --- a/src/pinecone/pinecone_validate.c +++ b/src/pinecone/pinecone_validate.c @@ -22,13 +22,23 @@ void validate_vector_nonzero(Vector* vector) { void pinecone_spec_validator(const PineconeOptions *opts) { - const char* spec_str = GET_STRING_RELOPTION(opts, spec); - if (opts == NULL || cJSON_Parse(spec_str) == NULL || (spec_str != NULL && strcmp(spec_str, "") == 0)){ + if (opts == NULL || cJSON_Parse(GET_STRING_RELOPTION(opts, spec)) == NULL) { ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("Invalid spec"), errhint("Spec should be a valid JSON object e.g. WITH (spec='{\"serverless\":{\"cloud\":\"aws\",\"region\":\"us-west-2\"}}').\n \ Refer to https://docs.pinecone.io/reference/create_index"))); + + } else { + const char* spec_str = GET_STRING_RELOPTION(opts, spec); + if (spec_str != NULL && strcmp(spec_str, "") == 0) { + ereport(ERROR, + (errcode(ERRCODE_INVALID_PARAMETER_VALUE), + errmsg("Invalid spec"), + errhint("Spec should be a valid JSON object e.g. WITH (spec='{\"serverless\":{\"cloud\":\"aws\",\"region\":\"us-west-2\"}}').\n \ + Refer to https://docs.pinecone.io/reference/create_index"))); + + } } }