Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typecast port to Number during configuration setup #382

Merged

Conversation

abhinaykumar
Copy link
Contributor

Hi,
Port number in string format results in error during deployment.

I was going through the quick start guide to setup the app and when I attempt to deploy the app with npx dbos-cloud app deploy it returned an error:

2024-04-14 13:53:35 [info]: Loaded application name from package.json: first-dbos-app
2024-04-14 13:53:35 [info]: Submitting deploy request for first-dbos-app
2024-04-14 13:53:40 [error]: [023805e5-9f3f-4b00-aecb-76dbe741bbfb] Failed to deploy application first-dbos-app: configuring application: 1 error(s) decoding:

* 'database.port' expected type 'int', got unconvertible type 'string', value: '5432'.

Step to reproduce the error

One thing I did differently is I entered the value (5432) manually instead of the letting it pick the default value.
This was during the setup step:

npx dbos configure
? What is the hostname of your Postgres server? localhost
? What is the port of your Postgres server? 5432
? What is your Postgres username? postgres

Reference in the codebase

I found the reference of the code and file which is responsible to saving the configurations to dbos-config.yaml file here: https://github.com/dbos-inc/dbos-transact/blob/main/src/dbos-runtime/configure.ts#L23

Description of how you tested the fix.

Before the fix:

> const inquirer = require("inquirer");
undefined
> let port;
undefined
>
> while (port !== 'exit') {
...   const output = await inquirer.prompt([
.....     {
.......       type: 'input',
.......       name: 'port',
.......       message: 'What is the port of your Postgres server? (Enter "exit" to quit)',
.......       // Providing a default value
.......       default: 5432,
.......     },
.....   ]);
...
...   port = output.port;
...   console.log(typeof output.port);
... }
? What is the port of your Postgres server? (Enter "exit" to quit) 5432
string

After the fix:

> while (port !== 'exit') {
...   const output = await inquirer.prompt([
.....     {
.......       type: 'input',
.......       name: 'port',
.......       message: 'What is the port of your Postgres server? (Enter "exit" to quit)',
.......       // Providing a default value
.......       default: 5432,
.......     },
.....   ]);
...
...   port = Number(output.port);
...   console.log(typeof port);
... }
? What is the port of your Postgres server? (Enter "exit" to quit) 5432
number

I am not sure if this is correct way of testing or even a valid fix in this case, please let me know if I am looking at the wrong direction. Thank you.

Copy link
Member

@qianl15 qianl15 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution! I tested it on my machine and it worked.

@qianl15 qianl15 merged commit 9cd4357 into dbos-inc:main Apr 14, 2024
2 checks passed
@abhinaykumar abhinaykumar deleted the bug-fix/configure-port-as-number branch April 15, 2024 04:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants