fix(core): Normalize person and shift IDs to strings#14
Draft
sentry[bot] wants to merge 1 commit into
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR addresses the
HTTPException: Error during optimization: Unknown person ID: 0which 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 internalmap_pid_pandmap_sid_sdictionaries, used for looking up person and shift type indices, were keyed by string representations of these IDs. This type mismatch causedutils.parse_pidsandutils.parse_sidsto fail with aValueErroras the integer ID was not found in the string-keyed map.Solution:
utils.py: Modifiedparse_pidsandparse_sidsto explicitly coerce incoming IDs to strings usingstr(id)before performing lookups inmap_pid_pandmap_sid_s. This ensures consistency with the string-keyed maps.scheduler.py: Symmetrically, updated the logic wheremap_pid_pandmap_sid_sare populated. All keys (individual person/shift IDs, and group IDs/members) are now explicitly converted to strings usingstr()when added to these maps. This guarantees that both the map creation and lookup operations consistently use string keys.ValueErrormessage inparse_pidsto includerepr(pid)and its type, providing clearer debugging information for future potential mismatches.Fixes JAVASCRIPT-NEXTJS-G