specifically the PUT [/v1/component/{componentName}/branch] Create new branch of a component endpoint.
Problem
Unable to add a new branch to existing component. Using the CLI, i created a request to create a new branch called 'dev-patrick'. But I get a return status of 500, saying 'error': 'Internal Server Error', 'path': '/v1/component/Oscilloscope/branch', 'errorCode': -1, 'errorMessage': 'The component is in use by other components'
So looking at the code, in the service/ComponentService.java, function addNewBranch(). The first wrapCatch() checks to see if the component exists, if it doesn't then it throws an error The component is in use by other components. Which isn't an accurate error description, it should be 'component not found'. Anyways, the real issue is that for some reason the component isn't being found despite it being added to the database.
Request to see list of components:
pnispero@PC100942:~$ curl -X 'GET' \
'https://ad-build-dev.slac.stanford.edu/api/cbs/v1/component' \
-H 'accept: application/json'
{"errorCode":0,"payload":[{"id":"66aab0f508804932f1aec7cd","name":"test-ioc","url":"https://github.com/ad-build-test/test-ioc","description":"test ioc for testing build system"},{"id":"66c77f6a8e1d990df9188471","name":"buildsystem","url":"https://github.com/ad-build-test/BuildSystem.git","description":"AD build system repo"},{"id":"671ac7959d22bd1d90cacd89","name":"oscilloscope","url":"https://github.com/ad-build-test/Oscilloscope","description":"Oscilloscope app taken from /afs/slac.stanford.edu/g/cd/swe/git/repos/slac/Oscilloscopes/Oscilloscope.git"}]}
Request to see Oscilloscope component in detail:
pnispero@PC100942:~$ curl -X 'GET' \
'https://ad-build-dev.slac.stanford.edu/api/cbs/v1/component/671ac7959d22bd1d90cacd89' \
-H 'accept: application/json'
{"errorCode":0,"payload":{"id":"671ac7959d22bd1d90cacd89","name":"oscilloscope","description":"Oscilloscope app taken from /afs/slac.stanford.edu/g/cd/swe/git/repos/slac/Oscilloscopes/Oscilloscope.git","organization":"ad-build-test","url":"https://github.com/ad-build-test/Oscilloscope","approvalRule":"ALL","testingCriteria":"ALL","dependOn":[],"buildOs":["RHEL7"],"componentToken":"36ab26d3-cae6-4ab5-8801-a82a172381f5","versions":[],"branches":[],"createdDate":"2024-10-24T22:17:57.77","lastModifiedDate":"2024-10-24T22:17:57.77"}}
Possible solution
I think the backend is not finding Oscilloscope because the O is not capitalized in the database. But when I made the component, I sent in a create new component request with a capital 'O' on the name.
I think the backend somewhere forces the new component name to be all lowercase, which isn't a concern for many repos, but some repos do have uppercase letters. And that can be problematic.
There is a small bug with adding a new branch
specifically the
PUT [/v1/component/{componentName}/branch] Create new branch of a component
endpoint.Problem
'error': 'Internal Server Error', 'path': '/v1/component/Oscilloscope/branch', 'errorCode': -1, 'errorMessage': 'The component is in use by other components'
service/ComponentService.java
, functionaddNewBranch()
. The firstwrapCatch()
checks to see if the component exists, if it doesn't then it throws an errorThe component is in use by other components
. Which isn't an accurate error description, it should be 'component not found'. Anyways, the real issue is that for some reason the component isn't being found despite it being added to the database.Request to see list of components:
Request to see Oscilloscope component in detail:
Possible solution
Oscilloscope
because theO
is not capitalized in the database. But when I made the component, I sent in acreate new component
request with a capital 'O' on the name.Original request with capital 'O'
New request with lowercase 'o'
I think the backend somewhere forces the new component name to be all lowercase, which isn't a concern for many repos, but some repos do have uppercase letters. And that can be problematic.