overleaf/overleaf · error

invalid v parameter

Error message

invalid v parameter

What it means

proxySyncPdf validates the ?v query parameter against /^-?\d+\.\d+$/, the same signed-decimal format as h. Missing, integer-only, comma-decimal, or non-numeric v values throw Error('invalid v parameter').

Source

Thrown at services/web/app/src/Features/Compile/CompileController.mjs:543

      buildId,
      file,
      clsiServerId,
      'output-file',
      req,
      res
    )
  },

  async proxySyncPdf(req, res) {
    const { page, h, v } = req.query
    if (!page?.match(/^\d+$/)) {
      throw new Error('invalid page parameter')
    }
    if (!h?.match(/^-?\d+\.\d+$/)) {
      throw new Error('invalid h parameter')
    }
    if (!v?.match(/^-?\d+\.\d+$/)) {
      throw new Error('invalid v parameter')
    }
    await _syncTeX(req, res, 'pdf', { page, h, v })
  },

  async proxySyncCode(req, res) {
    const { file, line, column } = req.query
    if (file == null) {
      throw new Error('missing file parameter')
    }
    // Check that we are dealing with a simple file path (this is not
    // strictly needed because synctex uses this parameter as a label
    // to look up in the synctex output, and does not open the file
    // itself).  Since we have valid synctex paths like foo/./bar we
    // allow those by replacing /./ with /
    const testPath = file.replace('/./', '/')
    if (Path.resolve('/', testPath) !== `/${testPath}`) {
      throw new Error('invalid file parameter')
    }

View on GitHub (pinned to 28ad3b03b7)

Solutions

  1. Serialize v with toFixed(2) so it always matches the signed-decimal format.
  2. Include v in the query even for zero: v=0.00.
  3. Fix the position-computation code that yields NaN or integers before the request.
  4. Convert any comma decimal separator to a dot client-side.

Example fix

// before
const params = { page, h, v } // v could be 7
fetch(`/project/${id}/sync/pdf?${new URLSearchParams(params)}`)
// after
const params = { page, h: Number(h).toFixed(2), v: Number(v).toFixed(2) }
fetch(`/project/${id}/sync/pdf?${new URLSearchParams(params)}`)
Defensive patterns

Strategy: validation

Validate before calling

function validCoord(v) { return /^-?\d+\.\d+$/.test(String(v)) }
// serialize: v.toFixed(2)

Type guard

function isSignedDecimal(v) { return typeof v === 'string' && /^-?\d+\.\d+$/.test(v) }

Try / catch

try {
  await syncPdf({ v })
} catch (err) {
  if (err.message === 'invalid v parameter') {
    // fix serialization (toFixed) and retry
  } else throw err
}

Prevention

When it happens

Trigger: GET /project/:Project_id/sync/pdf with v absent, v=0 (no decimal), v=10.5.3 (two dots), v=-10 (no fraction), or non-numeric text.

Common situations: Vertical PDF position serialized from an integer coordinate; v omitted because the caller considered it optional; locale comma decimals; NaN stringified as 'NaN' from an uninitialized position variable.

Understand the failure class

Background: "Invalid query parameter" / "Failed to parse value of ...": fixing bad query string parameters across APIs — this error's family across 36 libraries.

Related errors


AI-assisted analysis of overleaf/overleaf@28ad3b03b7 (2026-09-03). Data as JSON: /api/errors/0b65318b648ae68b. Report an issue: GitHub.