Skip to content
This repository has been archived by the owner on Aug 25, 2021. It is now read-only.

Invalid connection string not handled gracefully #528

Closed
do4gr opened this issue Jul 23, 2020 · 3 comments
Closed

Invalid connection string not handled gracefully #528

do4gr opened this issue Jul 23, 2020 · 3 comments
Assignees
Labels
bug/2-confirmed We have confirmed that this is a bug. kind/bug A reported bug. tech/typescript Issue for tech TypeScript. topic: cli

Comments

@do4gr
Copy link
Member

do4gr commented Jul 23, 2020

If I run migrate with a wrong password in my connection string env I get a proper error.

In my case I had a typo (the tick) in the port number, which led to an unhandled error:
DATABASE_URL="postgresql://postgres:prisma@localhost:543`/mydb?schema=public"
Screen Shot 2020-07-23 at 11 34 01

This case should also lead to a proper error.

I also tested this with the connection string directly in the schema and the error is the same. Introspection handles the error gracefully:

Screen Shot 2020-07-23 at 12 02 57

Versions:
@prisma/cli : 2.3.0
Current platform : darwin
Query Engine : query-engine e11114fa1ea826f9e7b4fa1ced34e78892fe8e0e (at node_modules/@prisma/cli/query-engine-darwin)
Migration Engine : migration-engine-cli e11114fa1ea826f9e7b4fa1ced34e78892fe8e0e (at node_modules/@prisma/cli/migration-engine-darwin)
Introspection Engine : introspection-core e11114fa1ea826f9e7b4fa1ced34e78892fe8e0e (at node_modules/@prisma/cli/introspection-engine-darwin)
Format Binary : prisma-fmt e11114fa1ea826f9e7b4fa1ced34e78892fe8e0e (at node_modules/@prisma/cli/prisma-fmt-darwin)

@do4gr do4gr changed the title Invalid connection string env not handled gracefully Invalid connection string not handled gracefully Jul 23, 2020
@tomhoule tomhoule added topic: cli kind/bug A reported bug. labels Jul 23, 2020
@Jolg42 Jolg42 added process/candidate Candidate for next Milestone. tech/typescript Issue for tech TypeScript. labels Aug 5, 2020
@Jolg42 Jolg42 self-assigned this Aug 5, 2020
@albertoperdomo albertoperdomo removed the process/candidate Candidate for next Milestone. label Aug 5, 2020
@albertoperdomo albertoperdomo added this to the Backlog 2.5.0 milestone Aug 5, 2020
@Jolg42
Copy link
Member

Jolg42 commented Aug 13, 2020

So it looks like the problem is that we call the engines and the command is then

command: '/Users/j42/Dev/prisma/src/packages/sdk/migration-engine-darwin cli --datasource postgresql://postgres:prisma@localhost:543`/mydb?schema=public can-connect-to-database'

And the engine returns

stdout: '',
    stderr: 'Aug 13 10:32:57.805  INFO migration_engine: Starting migration engine CLI git_hash="c0231c315abebc8c3ed7c32927a2a091bffda4a3"\n' +
      '{"is_panic":true,"message":"[/root/build/migration-engine/core/src/lib.rs:34:25] called `Result::unwrap()` on an `Err` value: InvalidPort","backtrace":"   0: backtrace::backtrace::trace\\n   1: backtrace::capture::Backtrace::new\\n   2: user_facing_errors::Error::new_in_panic_hook\\n   3: user_facing_errors::panic_hook::set_panic_hook::{{closure}}\\n   4: std::panicking::rust_panic_with_hook\\n   5: _rust_begin_unwind\\n   6: core::panicking::panic_fmt\\n   7: core::option::expect_none_failed\\n   8: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll\\n   9: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll\\n  10: migration_engine::main::{{closure}}\\n  11: tokio::runtime::enter::Enter::block_on\\n  12: tokio::runtime::context::enter\\n  13: tokio::runtime::handle::Handle::enter\\n  14: migration_engine::main\\n  15: std::rt::lang_start::{{closure}}\\n  16: std::rt::lang_start_internal\\n  17: _main\\n"}',

The expected error from engine is expected on stdout (no stderr) and with a response like

{
error_code: something,
message: "",
meta: ""
}

@Jolg42
Copy link
Member

Jolg42 commented Aug 13, 2020

I now output stderr in the case it exists and stdout is not empty
Screen Shot 2020-08-13 at 11 01 21

@Jolg42
Copy link
Member

Jolg42 commented Aug 13, 2020

New output with prisma/prisma-engines#1014
Screen Shot 2020-08-13 at 16 35 41

@janpio janpio added the bug/2-confirmed We have confirmed that this is a bug. label Aug 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug/2-confirmed We have confirmed that this is a bug. kind/bug A reported bug. tech/typescript Issue for tech TypeScript. topic: cli
Projects
None yet
Development

No branches or pull requests

5 participants