Skip to content

Conversation

@sudhanshu112233shukla
Copy link

Fixes:#596
This PR addresses issue #596 by adding Basic Authentication support to the Gerrit connection configuration, allowing Sourcebot to index repositories from Gerrit instances that require a username and password or HTTP token.

The approach consisted of updates across the schema, backend implementation, and testing. On the schema side, schemas/v3/gerrit.json was modified to include optional username and password fields in GerritConnectionConfig. After making this change, the schema types were regenerated by running yarn workspace @sourcebot/schemas build.

On the backend, changes were made in packages/backend/src/gerrit.ts. Both getGerritReposFromConfig and fetchAllProjects were updated to accept the new credential fields. Logic was added to construct a standard Basic Authentication header in the format Authorization: Basic base64(username:password). This header is injected into the fetch request only when both the username and password are provided, ensuring that existing behavior for public Gerrit instances remains unchanged and fully backward compatible.

For validation, a new and dedicated test suite was implemented in packages/backend/src/gerrit.test.ts to strictly verify the authentication logic. The tests confirm that the correct Authorization header is sent when both username and password are present, that no header is sent when credentials are missing, that partial credentials (such as only a username) do not trigger the header, and that credentials containing special characters (for example @ or :) are correctly Base64 encoded. All four tests passed successfully when run using the command yarn workspace @sourcebot/backend test src/gerrit.test.ts.

@coderabbitai
Copy link

coderabbitai bot commented Jan 20, 2026

Important

Review skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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