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

Cannot generate secret #552

Open
dmgursky opened this issue Jan 3, 2024 · 5 comments
Open

Cannot generate secret #552

dmgursky opened this issue Jan 3, 2024 · 5 comments
Labels
bug Issues where something isn't working as intended in the game.

Comments

@dmgursky
Copy link

dmgursky commented Jan 3, 2024

Describe the bug

Cannot generate secret for new deployment of massivedecks

How to reproduce the bug

I am trying to deploy a new instance of massivedecks to my private server via docker.

I have pulled a complete copy of md from Git Hub. In addition, I have put a copy of compose.yml from massivedecks/deployment
/memory/ into /md.

When I attempt to generate a new secret for config.json5 I get an error from the npm command:

_npm run generate-secret_

> @massivedecks/[email protected] generate-secret
> npm run prestart && node dist/secret.js


> @massivedecks/[email protected] prestart
> npm run build


> @massivedecks/[email protected] build
> npx tsc

src/ts/action/validation.validator.ts:16:24 - error TS2351: This expression is not constructable.
  Type 'typeof import("/md/server/node_modules/ajv/dist/ajv")' has no construct signatures.

16 export const ajv = new Ajv({
                          ~~~

src/ts/action/validation.validator.ts:21:1 - error TS2349: This expression is not callable.
  Type 'typeof import("/md/server/node_modules/ajv-formats/dist/index")' has no call signatures.

21 addFormats(ajv, { mode: "full" });
   ~~~~~~~~~~

src/ts/caches/postgres.ts:209:11 - error TS18047: 'result.rowCount' is possibly 'null'.

209       if (result.rowCount > 0) {
              ~~~~~~~~~~~~~~~

src/ts/caches/postgres.ts:241:11 - error TS18047: 'about.rowCount' is possibly 'null'.

241       if (about.rowCount > 0 && about.rows[0]["cards_updated"] !== undefined) {
              ~~~~~~~~~~~~~~

src/ts/store/postgres.ts:138:5 - error TS2322: Type 'number | null' is not assignable to type 'number'.
  Type 'null' is not assignable to type 'number'.

138     return await this.pg.withClient(async (client) => {
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
139       const result = await client.query(
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
... 
147       return result.rowCount;
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
148     });
    ~~~~~~~

src/ts/store/postgres.ts:243:11 - error TS18047: 'get.rowCount' is possibly 'null'.

243       if (get.rowCount < 1) {
              ~~~~~~~~~~~~


Found 6 errors in 3 files.

Errors  Files
     2  src/ts/action/validation.validator.ts:16
     2  src/ts/caches/postgres.ts:209
     2  src/ts/store/postgres.ts:138

Expected behaviour

I'm pretty sure that I am supposed to get a message to the effect of "Your secret is ..."

@dmgursky dmgursky added the bug Issues where something isn't working as intended in the game. label Jan 3, 2024
@dmgursky
Copy link
Author

dmgursky commented Jan 3, 2024

I have a fix for the error with "export const ajv = new Ajv", which is to use "export const ajv = new Ajv.default"

@Lattyware
Copy link
Owner

Apologies for the delay here, I'd suggest just generating a secret another way (any secure way of generating a random string) for now, and seeing if things work otherwise. This should be fixed with the next version, but no specific timeline on that right now.

@dmgursky
Copy link
Author

Apologies for the delay here, I'd suggest just generating a secret another way (any secure way of generating a random string) for now, and seeing if things work otherwise. This should be fixed with the next version, but no specific timeline on that right now.

First and foremost, thank you for taking the time to reply, but could you please reread my message -- I am getting errors on what should be fairly innocuous Typescript code. The comment about the Secret was meant as sarcasm. TY!

@Lattyware
Copy link
Owner

Apologies for the delay here, I'd suggest just generating a secret another way (any secure way of generating a random string) for now, and seeing if things work otherwise. This should be fixed with the next version, but no specific timeline on that right now.

First and foremost, thank you for taking the time to reply, but could you please reread my message -- I am getting errors on what should be fairly innocuous Typescript code. The comment about the Secret was meant as sarcasm. TY!

Yes, I could be wrong but I believe this is probably an error due to an incorrect tsconfig when running specifically to generate secrets, I believe it may work if you do a normal build, as the build did run through when the commit was made for the image. If not I'll have to take another look, although like I say this has all changed with the next version so whenever that comes it should fix things.

@dmgursky
Copy link
Author

Good morning and thank you (again) for writing back, but I am concerned there is a disconnect between our understanding here.

In the course of generating a secret to run massive decks, a script is executed with three steps (or I should more correctly say, the script fails on the third step):

npm run prestart && node dist/secret.js npm run build npx tsc

I receive four errors on this last step:

`src/ts/action/validation.validator.ts:13:24 - error TS2351: This expression is not constructable.
Type 'typeof import("/md/server/node_modules/ajv/dist/ajv")' has no construct signatures.

13 export const ajv = new Ajv({
~~~

src/ts/action/validation.validator.ts:18:1 - error TS2349: This expression is not callable.
Type 'typeof import("/md/server/node_modules/ajv-formats/dist/index")' has no call signatures.

18 addFormats(ajv, { mode: "full" });


src/ts/games/cards/sources/json-against-humanity.ts:239:28 - error TS2339: Property 'get' does not exist on type 'typeof import("/md/server/node_modules/axios/index")'.

239   const data = await Axios.get("", httpConfig);
                            ~~~

src/ts/games/cards/sources/many-decks.ts:154:35 - error TS2339: Property 'create' does not exist on type 'typeof import("/md/server/node_modules/axios/index")'.

154         create: async () => Axios.create(httpConfig),
                                   ~~~~~~


Found 4 errors in 3 files.

Errors  Files
  2  src/ts/action/validation.validator.ts:13
  1  src/ts/games/cards/sources/json-against-humanity.ts:239
  1  src/ts/games/cards/sources/many-decks.ts:154`

Here is my tsconfig.json file in /md/server

```
{
"$schema": "https://json.schemastore.org/tsconfig",

"include": ["src/**/*"],

"compilerOptions": {
 "lib": ["es2022"],
 "module": "nodenext",
 "target": "es2022",
 "moduleResolution": "nodenext",

 "sourceMap": true,
 "rootDir": "src/ts",
 "outDir": "dist",
 "removeComments": true,
 "newLine": "lf",

 "strict": true,
 "esModuleInterop": true,
 "skipLibCheck": true,
 "forceConsistentCasingInFileNames": true,
 "allowUnusedLabels": false,
 "noFallthroughCasesInSwitch": true,
 "noImplicitOverride": true,
 "noImplicitReturns": true,
 "noPropertyAccessFromIndexSignature": true,
 "noUncheckedIndexedAccess": true,
 "importsNotUsedAsValues": "error",
 "checkJs": true
}
}
```
It seems fairly innocuous to me.  Furthermore, it is (or should be) unchanged from the pull off of github.

FYSA, I am building this on a Raspberry Pi 4 I have lying around.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issues where something isn't working as intended in the game.
Projects
None yet
Development

No branches or pull requests

2 participants