fix: raise WorkSpaceError when the depot root cannot be resolved - #17
Open
nielsvaes wants to merge 1 commit into
Open
fix: raise WorkSpaceError when the depot root cannot be resolved#17nielsvaes wants to merge 1 commit into
nielsvaes wants to merge 1 commit into
Conversation
P4Client.__init__ ended with
self.depot_root = self.get_depot_paths([self.perforce_root])[0]
`p4 where` returns nothing when the client cannot talk to the server —
most commonly an expired ticket — so that indexed an empty list and
raised a bare `IndexError: list index out of range`.
The three checks immediately above it (P4USER, P4CLIENT, P4PORT) all
raise WorkSpaceError with a message naming what was missing; this one
did not. Callers that reconstruct a P4Client to recover a dropped
connection could not tell "log in again" from a genuine bug, and logged
the IndexError text instead. A downstream tool logged 7651 of them in
one session while retrying.
Now raises WorkSpaceError naming the path and pointing at `p4 login`.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
P4Client.__init__ended with:p4 wherereturns nothing when the client cannot talk to the server — most commonly an expired ticket — so that indexed an empty list and raised a bareIndexError: list index out of range.The three checks immediately above it all raise
WorkSpaceErrornaming what was missing:This one didn't, so a caller that reconstructs a
P4Clientto recover a dropped connection could not tell "log in again" apart from a genuine bug, and surfaced theIndexErrortext instead.How it turned up
A Maya tool that rebuilds its
P4Clienton a timer to recover from ticket expiry. One session logged 7651 consecutivereconnect: failed: list index out of rangewarnings over just under four hours. The message gave no indication that the fix wasp4 login, and it was indistinguishable from a bug in the tool.The change
Behaviour is unchanged when the depot root resolves. When it doesn't, the constructor now raises
WorkSpaceErrornaming the path and pointing atp4 login, instead ofIndexError.This is diagnostic only — the constructor failed before and fails now. Callers catching broad
Exceptionsee no behavioural difference; callers that catchp4errorscan now distinguish an auth failure from a real defect.Tests
Two added to
tests/test_p4client.py, both verified to fail against the old code with the exactIndexError: list index out of rangethis fixes:test_init_raises_workspace_error_when_depot_root_unresolvabletest_init_error_message_mentions_loginFull suite: 169 passed.
🤖 Generated with Claude Code
https://claude.ai/code/session_01DhkbNYwh15Ah9KLFQWXA8D