Merge request comments receive "download" link instead of inline code
Example: https://gitlab.com/musedev/muse/-/merge_requests/1153#note_479886310
When I post a merge request comment using the API it appears as two side-by-side windows with a 'download' link to the file:
In overview
In diff view
Steps to reproduce
I copied the following info from a duplicate issue: #281143 (closed)
Run the following command:
curl --request POST --header "Authorization: Bearer TOKEN" --form "body=Via API" --form "position[new_path]=test.js" --form "position[old_path]=test.js" --form "position[old_line]=20" --form "position[new_line]=20" --form "position[base_sha]=f36498b3f5ee3e31001774ee639accc7e0b8242c" --form "position[head_sha]=f36498b3f5ee3e31001774ee639accc7e0b8242c" --form "position[start_sha]=1f0fa02de1f6b913d674a8be10899fb8540237a9" --form "position[position_type]=text" https://gitlab.com/api/v4/projects/20486274/merge_requests/1/discussions
Which returns {"message":"500 Internal Server Error"}
base_sha
UPDATE: I've noticed that I've put in wrong "head_commit_sha": "f36498b3f5ee3e31001774ee639accc7e0b8242c",
- "base_commit_sha": "1f0fa02de1f6b913d674a8be10899fb8540237a9",
+ "base_commit_sha": "f36498b3f5ee3e31001774ee639accc7e0b8242c",
"start_commit_sha": "1f0fa02de1f6b913d674a8be10899fb8540237a9",
Relevant logs and/or screenshots
I cannot reproduce the issue locally, but this is the error in production logs:
message: Failed to find diff line for: test.js, old_line: 20, new_line: 20
class: DiffNote::NoteDiffFileCreationError
backtrace:
app/models/diff_note.rb:46:in `create_diff_file',
lib/gitlab/metrics/instrumentation.rb:160:in `block in create_diff_file',
lib/gitlab/metrics/method_call.rb:27:in `measure',
lib/gitlab/metrics/instrumentation.rb:160:in `create_diff_file',
config/initializers/forbid_sidekiq_in_transactions.rb:50:in `block in committed!',
config/initializers/forbid_sidekiq_in_transactions.rb:8:in `skipping_transaction_check',
config/initializers/forbid_sidekiq_in_transactions.rb:50:in `committed!',
ee/lib/gitlab/database/load_balancing/connection_proxy.rb:88:in `block in write_using_load_balancer',
ee/lib/gitlab/database/load_balancing/load_balancer.rb:84:in `block in read_write',
ee/lib/gitlab/database/load_balancing/load_balancer.rb:130:in `retry_with_backoff',
ee/lib/gitlab/database/load_balancing/load_balancer.rb:83:in `read_write',
ee/lib/gitlab/database/load_balancing/connection_proxy.rb:82:in `write_using_load_balancer',
ee/lib/gitlab/database/load_balancing/connection_proxy.rb:56:in `block (2 levels) in <class:ConnectionProxy>',
app/services/notes/create_service.rb:29:in `block in execute',
app/services/notes/create_service.rb:48:in `execute_quick_actions',
app/services/notes/create_service.rb:23:in `execute',
lib/api/helpers/notes_helpers.rb:129:in `create_note',
lib/api/discussions.rb:108:in `block (3 levels) in <class:Discussions>',
ee/lib/gitlab/middleware/ip_restrictor.rb:14:in `block in call',
ee/lib/gitlab/ip_address_state.rb:10:in `with',
ee/lib/gitlab/middleware/ip_restrictor.rb:13:in `call',
lib/api/api_guard.rb:208:in `call',
ee/lib/omni_auth/strategies/group_saml.rb:41:in `other_phase',
lib/gitlab/metrics/elasticsearch_rack_middleware.rb:16:in `call',
lib/gitlab/middleware/rails_queue_duration.rb:33:in `call',
lib/gitlab/metrics/rack_middleware.rb:16:in `block in call',
lib/gitlab/metrics/transaction.rb:61:in `run',
lib/gitlab/metrics/rack_middleware.rb:16:in `call',
lib/gitlab/request_profiler/middleware.rb:17:in `call',
ee/lib/gitlab/database/load_balancing/rack_middleware.rb:39:in `call',
lib/gitlab/jira/middleware.rb:19:in `call',
lib/gitlab/middleware/go.rb:20:in `call',
lib/gitlab/etag_caching/middleware.rb:13:in `call',
lib/gitlab/middleware/multipart.rb:234:in `call',
lib/gitlab/middleware/read_only/controller.rb:51:in `call',
lib/gitlab/middleware/read_only.rb:18:in `call',
lib/gitlab/middleware/same_site_cookies.rb:27:in `call',
lib/gitlab/middleware/handle_malformed_strings.rb:19:in `call',
lib/gitlab/middleware/basic_health_check.rb:25:in `call',
lib/gitlab/middleware/handle_ip_spoof_attack_error.rb:25:in `call',
lib/gitlab/middleware/request_context.rb:23:in `call',
config/initializers/fix_local_cache_middleware.rb:9:in `call',
lib/gitlab/metrics/requests_rack_middleware.rb:76:in `call',
lib/gitlab/middleware/release_env.rb:12:in `call'
Generally one expects to see the actual code such as here.
Edited by Tomas Vik (OOO back on 2024-11-19)