fix: handle nil OAuth application in commits API
What does this MR do and why?
Fixes a 500 internal server error when creating commits through the API using OAuth password grant tokens (where application is nil).
The web_ide_request? helper method attempted to call .id on access_token.application without checking if it was nil first. This caused a when using an oauth token with application being nil.
While the commit was successfully created, the API returned a 500 error instead of 201, breaking client integrations and CI/CD pipelines.
References
Closes #569048
How to set up and validate locally
- Start your GDK instance
- Get an OAuth token using password grant:
export GITLAB_TOKEN=$(curl -sS --data "grant_type=password&username=root&password=YOUR_PASSWORD" --request POST "http://<your_gdk_url>/oauth/token" | jq -r .access_token)
- Create a commit using that token:
curl -X POST "http://<your_gdk_url>/api/v4/projects/:id/repository/commits" -H "Authorization: Bearer $GITLAB_TOKEN" -H "Content-Type: application/json" -d '{"branch": "<your_branch>", "commit_message": "Test commit", "actions": [{"action": "create", "file_path": "test.txt", "content": "test"}]}'
- Verify you get a 201 Created response (not 500 internal server error message)
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.