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

Preflight Docker container with PostgreSQL database: opts.uid is NaN #588

Open
karlhorky opened this issue Oct 17, 2024 · 1 comment
Open
Assignees

Comments

@karlhorky
Copy link
Member

One of the latest Preflight test runs failed with the error The "options.uid" property must be int32. Received type number (NaN):

(node:1) ExperimentalWarning: Type Stripping is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
Cloning https://github.com/LrDevEng/next-ecommerce-store...
Installing dependencies...
Setting up PostgreSQL database...
file:///preflight/node_modules/.pnpm/[email protected]/node_modules/execa/lib/return/final-error.js:6
	return new ErrorClass(message, options);
	       ^

ExecaError: Command failed with ERR_INVALID_ARG_TYPE: bash ./scripts/alpine-postgresql-setup-and-start.sh
The "options.uid" property must be int32. Received type number (NaN)
    at getFinalError (file:///preflight/node_modules/.pnpm/[email protected]/node_modules/execa/lib/return/final-error.js:6:9)
    at makeError (file:///preflight/node_modules/.pnpm/[email protected]/node_modules/execa/lib/return/result.js:108:16)
    at makeEarlyError (file:///preflight/node_modules/.pnpm/[email protected]/node_modules/execa/lib/return/result.js:45:7)
    at handleEarlyError (file:///preflight/node_modules/.pnpm/[email protected]/node_modules/execa/lib/return/early-error.js:21:21)
    at spawnSubprocessAsync (file:///preflight/node_modules/.pnpm/[email protected]/node_modules/execa/lib/methods/main-async.js:80:10)
    at execaCoreAsync (file:///preflight/node_modules/.pnpm/[email protected]/node_modules/execa/lib/methods/main-async.js:26:32)
    ... 2 lines matching cause stack trace ...
    at file:///preflight/clone-and-preflight.ts:74:5 {
  shortMessage: 'Command failed with ERR_INVALID_ARG_TYPE: bash ./scripts/alpine-postgresql-setup-and-start.sh\n' +
    'The "options.uid" property must be int32. Received type number (NaN)',
  originalMessage: 'The "options.uid" property must be int32. Received type number (NaN)',
  command: 'bash ./scripts/alpine-postgresql-setup-and-start.sh',
  escapedCommand: 'bash ./scripts/alpine-postgresql-setup-and-start.sh',
  cwd: '/preflight/project-to-check',
  durationMs: 3.228265,
  failed: true,
  timedOut: false,
  isCanceled: false,
  isGracefullyCanceled: false,
  isTerminated: false,
  isMaxBuffer: false,
  isForcefullyTerminated: false,
  code: 'ERR_INVALID_ARG_TYPE',
  stdio: [ undefined, undefined, undefined ],
  ipcOutput: [],
  pipedFrom: [],
  [cause]: TypeError [ERR_INVALID_ARG_TYPE]: The "options.uid" property must be int32. Received type number (NaN)
      at normalizeSpawnArguments (node:child_process:586:11)
      at spawn (node:child_process:754:13)
      at spawnSubprocessAsync (file:///preflight/node_modules/.pnpm/[email protected]/node_modules/execa/lib/methods/main-async.js:78:16)
      at execaCoreAsync (file:///preflight/node_modules/.pnpm/[email protected]/node_modules/execa/lib/methods/main-async.js:26:32)
      at callBoundExeca (file:///preflight/node_modules/.pnpm/[email protected]/node_modules/execa/lib/methods/create.js:44:5)
      at boundExeca (file:///preflight/node_modules/.pnpm/[email protected]/node_modules/execa/lib/methods/create.js:15:44)
      at file:///preflight/clone-and-preflight.ts:74:5 {
    code: 'ERR_INVALID_ARG_TYPE'
  }
}

Node.js v22.9.0

This appears to be coming from this uid being passed here, calculated from Number(await execa`id -u postgres`):

// Run script as postgres user to:
// - Create data directory
// - Init database
// - Start database
// - Create database
// - Create database user
// - Create schema
// - Grant permissions to database user
//
// Example script:
// https://github.com/upleveled/preflight-test-project-next-js-passing/blob/e65717f6951b5336bb0bd83c15bbc99caa67ebe9/scripts/alpine-postgresql-setup-and-start.sh
const postgresUid = Number(await execa`id -u postgres`);
await execa({
// postgres user, for initdb and pg_ctl
uid: postgresUid,
// Show output to simplify debugging
stdout: 'inherit',
stderr: 'inherit',
})`bash ./scripts/alpine-postgresql-setup-and-start.sh`;

We need to investigate why the postgres user does not return an id - maybe the user doesn't exist?

@karlhorky karlhorky changed the title opts.uid is NaN Preflight Docker container with PostgreSQL database: opts.uid is NaN Oct 17, 2024
@karlhorky
Copy link
Member Author

karlhorky commented Oct 17, 2024

Maybe this was related to the recent change to add coreutils (includes id) and node:22-alpine?

I can't think of any other (recent) changes that would have affected this.

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

No branches or pull requests

2 participants