Use Gitaly Exception Message to Check for Path
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 (closed)
How to set up and validate locally
-
Update your
gdk.yml
to enable all feature flags forgitaly
so we can enable commit: Use structured errors in `GetTreeEntrie... (gitaly!5895 - merged):gitaly: enable_all_feature_flags: true
-
Reconfigure GDK and restart gitaly -
gdk reconfigure && gdk restart gitaly
-
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'
-
Observe
[]
and 200 is returned. -
Enable the feature flag in the Rails console:
Feature.enable(:handle_structured_gitaly_errors)
-
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'
-
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.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #404955 (closed)