louislam/dockge · error · Error

Wrong data type?

Error message

Wrong data type?

What it means

doubleCheckPassword() in backend/util-server.ts requires the currentPassword argument to be a string before it will verify it against the stored hash. If the client sends anything else (undefined, null, object, number), the function throws 'Wrong data type?' to fail fast rather than passing a non-string to verifyPassword. It guards sensitive operations like changing account settings (user) or creating changes that require re-authentication.

Source

Thrown at backend/util-server.ts:88

            msg: error.message,
            msgi18n: true,
        });
    } else {
        log.debug("console", "Unknown error: " + error);
    }
}

export function callbackResult(result : unknown, callback : unknown) {
    if (typeof(callback) !== "function") {
        log.error("console", "Callback is not a function");
        return;
    }
    callback(result);
}

export async function doubleCheckPassword(socket : DockgeSocket, currentPassword : unknown) {
    if (typeof currentPassword !== "string") {
        throw new Error("Wrong data type?");
    }

    let user = await R.findOne("user", " id = ? AND active = 1 ", [
        socket.userID,
    ]);

    if (!user || !verifyPassword(currentPassword, user.password)) {
        throw new Error("Incorrect current password");
    }

    return user;
}

export function fileExists(file : string) {
    return fs.promises.access(file, fs.constants.F_OK)
        .then(() => true)
        .catch(() => false);
}

View on GitHub (pinned to f809ae192b)

Solutions

  1. Ensure the current-password field is filled in before emitting the event
  2. Coerce/trim the value and confirm typeof === 'string' on the client before sending
  3. Fix custom API clients to send currentPassword as a plain string
  4. Check the frontend form binding so the field value is actually included in the payload

Example fix

// before
socket.emit("changePassword", this.newPassword); // currentPassword missing
// after
if (typeof this.currentPassword === "string" && this.currentPassword.length > 0) {
  socket.emit("changePassword", this.currentPassword, this.newPassword);
}
Defensive patterns

Strategy: type-guard

Validate before calling

if (typeof currentPassword !== "string" || currentPassword.length === 0) {
  showError("Please enter your current password.");
  return;
}

Type guard

function isNonEmptyString(v) {
  return typeof v === "string" && v.length > 0;
}

Try / catch

try {
  await doubleCheckPassword(socket, currentPassword);
} catch (e) {
  if (e.message === "Wrong data type?") {
    showError("Current password field was missing or malformed.");
  } else if (e.message === "Incorrect current password") {
    showError("Password is wrong.");
  } else throw e;
}

Prevention

When it happens

Trigger: Emitting a socket handler that calls doubleCheckPassword with a missing, undefined, non-string currentPassword field — e.g. form submitted without filling the current-password input, or a custom client sending a wrong-shaped payload.

Common situations: Frontend state lost so the password field is undefined at submit time; API scripts sending JSON where the password is a number or nested object; older/foreign clients not matching the expected payload shape.

Understand the failure class

Background: "Wrong argument type", "must be a string", "expected Array or Prism::Scope": TypeError and ArgumentError when a library receives a value of the wrong type — this error's family across 28 libraries.

Related errors


AI-assisted analysis of louislam/dockge@f809ae192b (2026-08-31). Data as JSON: /api/errors/02f7b0131c4a2f0e. Report an issue: GitHub.