Skip to content

Commit

Permalink
qe: Default make-qe task to JSON protocol and improve error message (
Browse files Browse the repository at this point in the history
…#4644)

* qe: Default `make-qe` task to JSON protocol and improve error message

I beleive prisma/team-orm#710 was caused by engine defaulting to GraphQL
via `.envrc` file. Error handling in BinaryEngine
being broken in this case (prisma/prisma#22636) made finding this out
really hard.
So, while main fix is done on the client side, I beleive we can adjust
few things on the engine side too:

- `make-qe` task will now always use JSON protocol.
- `make-qe-graphql` task added for cases where it is necessary. For
  example, using the playground.
- Default `PRISMA_ENGINE_PROTOCOL` is removed from `.envrc`. If needed,
  it can be restored via `.envrc.local`.
- Error message adjusted to mention incorrect protocol possiblity.

Contributes to prisma/team-orm#710

* Update blackbox test

* And again
  • Loading branch information
SevInf authored Jan 16, 2024
1 parent 476ee04 commit b35b06e
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
1 change: 0 additions & 1 deletion .envrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export RUST_LOG=info
export PRISMA_DML_PATH=$(pwd)/dev_datamodel.prisma
export PRISMA2_BINARY_PATH="/usr/local/lib/node_modules/prisma2/"
export PRISMA_BINARY_PATH=$(pwd)/target/release/query-engine
export PRISMA_ENGINE_PROTOCOL="graphql"

### QE config vars, set to testing values ###
export SQLITE_MAX_VARIABLE_NUMBER=250000 # This must be in sync with the setting in the engineer build CLI
Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,10 @@ validate:
cargo run --bin test-cli -- validate-datamodel dev_datamodel.prisma

qe:
cargo run --bin query-engine -- --enable-playground --enable-raw-queries --enable-metrics --enable-open-telemetry --enable-telemetry-in-response
cargo run --bin query-engine -- --engine-protocol json --enable-raw-queries --enable-metrics --enable-open-telemetry --enable-telemetry-in-response

qe-graphql:
cargo run --bin query-engine -- --engine-protocol graphql --enable-playground --enable-raw-queries --enable-metrics --enable-open-telemetry --enable-telemetry-in-response

qe-dmmf:
cargo run --bin query-engine -- cli dmmf > dmmf.json
Expand Down
4 changes: 2 additions & 2 deletions query-engine/black-box-tests/tests/protocols/mismatched.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ mod mismatched {
.unwrap();

assert_eq!(res.status(), reqwest::StatusCode::UNPROCESSABLE_ENTITY);
insta::assert_snapshot!(res.text().await.unwrap(), @r###"{"is_panic":false,"message":"Error parsing Json query. data did not match any variant of untagged enum JsonBody","backtrace":null}"###);
insta::assert_snapshot!(res.text().await.unwrap(), @r###"{"is_panic":false,"message":"Error parsing Json query. Ensure that engine protocol of the client and the engine matches. data did not match any variant of untagged enum JsonBody","backtrace":null}"###);
})
.await
}
Expand All @@ -83,7 +83,7 @@ mod mismatched {
.unwrap();

assert_eq!(res.status(), reqwest::StatusCode::UNPROCESSABLE_ENTITY);
insta::assert_snapshot!(res.text().await.unwrap(), @r###"{"is_panic":false,"message":"Error parsing Graphql query. data did not match any variant of untagged enum GraphqlBody","backtrace":null}"###);
insta::assert_snapshot!(res.text().await.unwrap(), @r###"{"is_panic":false,"message":"Error parsing Graphql query. Ensure that engine protocol of the client and the engine matches. data did not match any variant of untagged enum GraphqlBody","backtrace":null}"###);
})
.await
}
Expand Down
2 changes: 1 addition & 1 deletion query-engine/query-engine/src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ async fn request_handler(cx: Arc<PrismaContext>, req: Request<Body>) -> Result<R
}
Err(e) => {
let ufe: user_facing_errors::Error = request_handlers::HandlerError::query_conversion(format!(
"Error parsing {:?} query. {}",
"Error parsing {:?} query. Ensure that engine protocol of the client and the engine matches. {}",
cx.engine_protocol(),
e
))
Expand Down

0 comments on commit b35b06e

Please sign in to comment.