Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prettify error message for catch-all conflict with existing path segment #2934

Merged
merged 1 commit into from Nov 28, 2021

Conversation

SericaLaw
Copy link
Contributor

@SericaLaw SericaLaw commented Nov 12, 2021

Hi, I find that the conflict message for catch-all wildcard with existing path segment is not clear enough during my use of gin framework, i.e. it only suggests that there is a conflict, but gives no hint about where the conflict is.

This PR will give a more user-friendly error message when users are trying to add two conflict routes as bellow:

r := New()
r.GET("/foo/bar", nil)
r.GET("/foo/*bar", nil)

Error message before:

catch-all conflicts with existing handle for the path segment root in path '/foo/*bar' 

Error message now:

catch-all wildcard '*bar' in new path '/foo/*bar' conflicts with existing path segment 'bar' in existing prefix '/foo/bar'

@codecov
Copy link

codecov bot commented Nov 24, 2021

Codecov Report

Merging #2934 (e1ee5ca) into master (823adfc) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #2934   +/-   ##
=======================================
  Coverage   98.57%   98.57%           
=======================================
  Files          41       41           
  Lines        3080     3085    +5     
=======================================
+ Hits         3036     3041    +5     
  Misses         31       31           
  Partials       13       13           
Flag Coverage Δ
go-1.13 ∅ <ø> (∅)
go-1.14 ∅ <ø> (∅)
go-1.15 ∅ <ø> (∅)
go-1.16 98.57% <100.00%> (+<0.01%) ⬆️
go-1.17 98.47% <100.00%> (+<0.01%) ⬆️
macos-latest 98.57% <100.00%> (+<0.01%) ⬆️
nomsgpack 98.55% <100.00%> (+<0.01%) ⬆️
ubuntu-latest 98.57% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
tree.go 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 823adfc...e1ee5ca. Read the comment docs.

@SericaLaw
Copy link
Contributor Author

@appleboy @thinkerou Hi, sorry to bother, any suggestions about this change and the diff coverage? I have no idea why my changes will remove coverage for debugPrintWARNINGDefault() func in debug.go.

@Bisstocuz
Copy link
Contributor

Bisstocuz commented Nov 25, 2021

@appleboy @thinkerou Hi, sorry to bother, any suggestions about this change and the diff coverage? I have no idea why my changes will remove coverage for debugPrintWARNINGDefault() func in debug.go.

Try to merge from upstream/master and check it again?

Copy link
Contributor

@Bisstocuz Bisstocuz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may need to add some unit test cases for this change, too.

tree.go Show resolved Hide resolved
Copy link
Member

@thinkerou thinkerou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@thinkerou thinkerou merged commit a06d546 into gin-gonic:master Nov 28, 2021
daheige pushed a commit to daheige/gin that referenced this pull request Apr 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants