Skip to content

NPE parsing Bitbucket Server browse URL without ?at= #23766

@dlsiddon

Description

@dlsiddon

Describe the bug

When looking at the "browse" URL "?at=" is not added when you are looking at the default branch for a bitbucket repo resulting a NullPointerException.

Adding "?at=" or HTTPS clone or SSH clone URLs will successfully start a workspace.
Navigating to branches that are not default will generate a proper "browse" URL link as well.

Product/Version: Red Hat OpenShift Dev Spaces 3.26

Component: Bitbucket Server factory URL parsing

Source: BitbucketServerURLParser.java at commit 59b10adc99025c9750df5f31d71d9c297c68217e
https://github.com/eclipse-che/che-server/blob/59b10adc99025c9750df5f31d71d9c297c68217e/wsmaster/che-core-api-factory-bitbucket-server/src/main/java/org/eclipse/che/api/factory/server/bitbucket/BitbucketServerURLParser.java

Che version

7.115@latest

Steps to reproduce

Use a Bitbucket Server “browse” URL that has no query params (default branch), e.g.
https://(bb-host)/projects/(proj)/repos/(repo)/browse
Trigger factory/workspace creation (whatever feature in Dev Spaces invokes this parser)
Actual result: Cannot invoke "String.startsWith(String)" because "branch" is null

Expected behavior

Browse URL without ?at= should parse successfully and either:

fall back to the revision argument passed to parse(url, revision), or
leave branch unset and let later logic resolve the default branch.
Root cause: In parse(Matcher, revision), matcher.group("branch") can be null when ?at= is absent (the regex group exists but doesn’t match). Code calls branch.startsWith(...) without a null check.

Runtime

OpenShift

Screenshots

Image

Installation method

OperatorHub

Environment

Linux

Eclipse Che Logs

Additional context

No response

Metadata

Metadata

Assignees

Labels

area/che-serverkind/bugOutline of a bug - must adhere to the bug report template.severity/P1Has a major impact to usage or development of the system.

Type

No type

Projects

Status

✅ Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions