Roll20 / Roll20/roll20-api-scripts

Sandbox crash when lvlX_slots_expended is NaN (easy fix)

Open
#1,410 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
407
Forks
602
Avg merge
7d 55m
Merged PRs (30d)
18

Description

5e Companion

As per this Roll20 thread, non-numeric values in lvlX_slots_expended will cause the resolveslot() function to crash the API sandbox. The issue is with HTML's handling of number inputs, largely with whitespace as the error is invisible to the user, but the attribute value becomes an empty string.
An easy solution would be to change line 320, the .set() operation, to check for isNaN:
if (!isNaN(spent)) charslot.set({current: Math.max(spent - 1, 0)});

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in the resolveslot() function at the .set() operation on line 320, using the issue's reproduction context around non-numeric lvlX_slots_expended values. Verify the handling of empty or NaN input and confirm that resolving a slot no longer crashes the API sandbox while valid numeric values still update correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
backend
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.