(Translated by https://www.hiragana.jp/)
Route data maps ignore meta-merge options in 0.7.0, breaking compatibility · Issue #679 · metosin/reitit · GitHub
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

Route data maps ignore meta-merge options in 0.7.0, breaking compatibility #679

Closed
svdm opened this issue May 1, 2024 · 3 comments · Fixed by #688
Closed

Route data maps ignore meta-merge options in 0.7.0, breaking compatibility #679

svdm opened this issue May 1, 2024 · 3 comments · Fixed by #688
Assignees
Labels

Comments

@svdm
Copy link

svdm commented May 1, 2024

In 0.6.0, nested map data is merged in a way that matches meta-merge, supporting ^:replace:

user> (meta-merge {:roles {:foo false :bar true}} {:roles ^:replace {:foo true}})
{:roles {:foo true}}

user> (r/routes (r/router
                 ["/context" {:roles {:foo false :bar true}}
                  ["/leaf" {:roles ^:replace {:foo true}}]]))
[["/context/leaf" {:roles {:foo true}}]]

In 0.7.0, this is no longer the case, ^:replace is not respected:

user> (r/routes (r/router
                 ["/context" {:roles {:foo false :bar true}}
                  ["/leaf" {:roles ^:replace {:foo true}}]]))
[["/context/leaf" {:roles {:foo true, :bar true}}]]

This is not documented in the changelog so I assume it's not intentional.

@svdm svdm changed the title Route data maps merge differently in 0.7.0, breaking compatibility Route data maps ignore meta-merge in 0.7.0, breaking compatibility Jun 25, 2024
@svdm
Copy link
Author

svdm commented Jun 25, 2024

I have found a workaround of sorts by fully disabling :update-paths functionality:

user> (r/routes (r/router
                 ["/context" {:roles {:foo false :bar true}}
                  ["/leaf" {:roles ^:replace {:foo true}}]]
                 {:update-paths nil}))
[["/context/leaf" {:roles {:foo true}}]]

As a result presumably losing out on the schema merging fixes. (edit: Actually seems to cause more fundamental errors with plumatic schemas, so it's not a practical workaround.)

The root cause of the issue is that update-paths strips metadata from nested maps (strictly: rebuilds the maps from scratch without retaining metadata), preventing meta-merge from ever seeing it, so it's not surprising that meta-merge directives on maps have no effect.

@svdm svdm changed the title Route data maps ignore meta-merge in 0.7.0, breaking compatibility Route data maps ignore meta-merge options in 0.7.0, breaking compatibility Jun 25, 2024
@ikitommi
Copy link
Member

You are right, this is a regression.

@ikitommi ikitommi added the bug label Jun 30, 2024
@ikitommi ikitommi self-assigned this Jun 30, 2024
@ikitommi ikitommi mentioned this issue Jun 30, 2024
@ikitommi
Copy link
Member

ikitommi commented Jul 6, 2024

fixed and released in 0.7.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants