Skip to content

refactor: make HTTP error code parsing robust#1013

Open
saiashok0981 wants to merge 1 commit into
goharbor:mainfrom
saiashok0981:fix/robust-error-code-parsing
Open

refactor: make HTTP error code parsing robust#1013
saiashok0981 wants to merge 1 commit into
goharbor:mainfrom
saiashok0981:fix/robust-error-code-parsing

Conversation

@saiashok0981

Copy link
Copy Markdown

Branch: fix/robust-error-code-parsing
Commit: [fix/robust-error-code-parsing e275281]
Changes:
Refactored ParseHarborErrorCode in
error.go
to use a regular expression:
go

reBracket := regexp.MustCompile(\]\s*\[(\d{3})\])
This matches any 3-digit status code enclosed in brackets that is preceded by a closing bracket (with or without spaces), rather than relying on splitting string indices.
Added new comprehensive unit test cases in
error_test.go
to ensure reliability for wrapped bracketed messages, spaced bracket formats, and prefix brackets.

Signed-off-by: saiashok103@gmail.com
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.

1 participant