Skip to content

fix(core): Normalize person and shift IDs to strings#14

Draft
sentry[bot] wants to merge 1 commit into
devfrom
seer/fix/normalize-person-shift-ids
Draft

fix(core): Normalize person and shift IDs to strings#14
sentry[bot] wants to merge 1 commit into
devfrom
seer/fix/normalize-person-shift-ids

Conversation

@sentry

@sentry sentry Bot commented May 21, 2026

Copy link
Copy Markdown
Contributor

This PR addresses the HTTPException: Error during optimization: Unknown person ID: 0 which occurred when processing scheduling preferences.

Problem:
The issue arose because YAML input, when containing unquoted numeric IDs (e.g., person: 0), would parse these IDs as integers. However, the internal map_pid_p and map_sid_s dictionaries, used for looking up person and shift type indices, were keyed by string representations of these IDs. This type mismatch caused utils.parse_pids and utils.parse_sids to fail with a ValueError as the integer ID was not found in the string-keyed map.

Solution:

  1. utils.py: Modified parse_pids and parse_sids to explicitly coerce incoming IDs to strings using str(id) before performing lookups in map_pid_p and map_sid_s. This ensures consistency with the string-keyed maps.
  2. scheduler.py: Symmetrically, updated the logic where map_pid_p and map_sid_s are populated. All keys (individual person/shift IDs, and group IDs/members) are now explicitly converted to strings using str() when added to these maps. This guarantees that both the map creation and lookup operations consistently use string keys.
  3. Error Message Improvement: Enhanced the ValueError message in parse_pids to include repr(pid) and its type, providing clearer debugging information for future potential mismatches.

Fixes JAVASCRIPT-NEXTJS-G

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

Successfully merging this pull request may close these issues.

0 participants