{"record":{"id":"a92f4bb5a27f5d7d","repo":"meteor/meteor","slug":"history-go-history-go-requires-a-positive-or-nega","errorCode":null,"errorMessage":"History.go: History.go requires a positive or negative integer passed.","messagePattern":"History\\.go: History\\.go requires a positive or negative integer passed\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/deprecated/jquery-history/history.js","lineNumber":1576,"sourceCode":"\n\t\t\t// Prepare\n\t\t\tvar i;\n\n\t\t\t// Handle\n\t\t\tif ( index > 0 ) {\n\t\t\t\t// Forward\n\t\t\t\tfor ( i=1; i<=index; ++i ) {\n\t\t\t\t\tHistory.forward(queue);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if ( index < 0 ) {\n\t\t\t\t// Backward\n\t\t\t\tfor ( i=-1; i>=index; --i ) {\n\t\t\t\t\tHistory.back(queue);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tthrow new Error('History.go: History.go requires a positive or negative integer passed.');\n\t\t\t}\n\n\t\t\t// Chain\n\t\t\treturn History;\n\t\t};\n\n\n\t\t// ====================================================================\n\t\t// HTML5 State Support\n\n\t\t// Non-Native pushState Implementation\n\t\tif ( History.emulated.pushState ) {\n\t\t\t/*\n\t\t\t * Provide Skeleton for HTML4 Browsers\n\t\t\t */\n\n\t\t\t// Prepare\n\t\t\tvar emptyFunction = function(){};","sourceCodeStart":1558,"sourceCodeEnd":1594,"githubUrl":"https://github.com/meteor/meteor/blob/5076d2f818d3cac01d0cf8312fa5b2332076a4fb/packages/deprecated/jquery-history/history.js#L1558-L1594","documentation":"History.go(index) only accepts a non-zero integer: positive moves forward, negative moves backward. Passing 0 (or a value that is neither >0 nor <0) falls through both branches and throws, because moving by zero states is meaningless.","triggerScenarios":"Calling History.go(0); calling History.go(someVar) where someVar is 0, undefined coerced to 0, or NaN.","commonSituations":"Passing a computed delta that can be zero; user input (e.g. 'go N steps') with N=0; off-by-one in pagination logic.","solutions":["Guard: only call History.go when index is a non-zero integer.","No-op explicitly when index === 0 rather than calling History.go.","Coerce and validate: if (!index || !Number.isInteger(index)) return;"],"exampleFix":"// before\nHistory.go(delta); // delta may be 0\n\n// after\nif (Number.isInteger(delta) && delta !== 0) History.go(delta);","handlingStrategy":"validation","validationCode":"function historyGo(index) {\n  if (!Number.isInteger(index) || index === 0) return;\n  History.go(index);\n}","typeGuard":"function isNonZeroInteger(v) {\n  return Number.isInteger(v) && v !== 0;\n}","tryCatchPattern":null,"preventionTips":["Coerce and validate user input before passing to History.go.","No-op explicitly when delta is zero.","Unit-test navigation code with zero/NaN inputs."],"tags":["history","input-validation","navigation"],"backgroundTag":null,"analyzedSha":"5076d2f818d3cac01d0cf8312fa5b2332076a4fb","analyzedAt":"2026-08-13T03:27:40.142Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}