Skip to content

Use Gitaly Exception Message to Check for Path

Gavin Hinfey requested to merge 404955-handle-structured-gitaly-errors into master

What does this MR do and why?

When the handle_structured_gitaly_errors feature flag is enabled it handles exception message from Gitaly to return 404 if path not found. Currently if a path is not found repository/tree returns [].

To do this a parameter rescue_not_found has been added to the tree_entries method.

Contributes to #18549 (closed)
Contributes to #404955 (closed)
Feature Flag: #420865

How to set up and validate locally

  1. Update your gdk.yml to enable all feature flags for gitaly so we can enable commit: Use structured errors in `GetTreeEntrie... (gitaly!5895 - merged):

    gitaly:
      enable_all_feature_flags: true
  2. Reconfigure GDK and restart gitaly - gdk reconfigure && gdk restart gitaly

  3. Run this API query against the GDK where 2 (gitlab-org/gitlab-test) is a public project id:

    curl -i 'http://127.0.0.1:3000/api/v4/projects/2/repository/tree?path=bogus'
  4. Observe [] and 200 is returned.

  5. Enable the feature flag in the Rails console:

    Feature.enable(:handle_structured_gitaly_errors)
  6. Run this API query against the GDK where 2 (gitlab-org/gitlab-test) is a public project id:

    curl -i 'http://127.0.0.1:3000/api/v4/projects/2/repository/tree?path=bogus'
  7. Observe {"message":"404 invalid revision or path Not Found"} and 404 is returned.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #404955 (closed)

Edited by Ash McKenzie

Merge request reports