Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Metabase
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Engineering Digital Service
Metabase
Commits
67b9f068
Unverified
Commit
67b9f068
authored
2 years ago
by
Bryan Maass
Committed by
GitHub
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
skip the error messages for :string + remove fatal (#29380)
parent
d438e16d
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/metabase/api/common/internal.clj
+29
-21
29 additions, 21 deletions
src/metabase/api/common/internal.clj
with
29 additions
and
21 deletions
src/metabase/api/common/internal.clj
+
29
−
21
View file @
67b9f068
...
...
@@ -4,6 +4,7 @@
(
:require
[
clojure.string
:as
str
]
[
clojure.walk
:as
walk
]
[
colorize.core
:as
colorize
]
[
malli.core
:as
mc
]
[
malli.error
:as
me
]
[
malli.transform
:as
mtx
]
...
...
@@ -14,6 +15,7 @@
[
metabase.util.log
:as
log
]
[
metabase.util.malli
:as
mu
]
[
metabase.util.malli.describe
:as
umd
]
[
metabase.util.malli.schema
:as
ms
]
[
metabase.util.schema
:as
su
]
[
potemkin.types
:as
p.types
]
[
schema.core
:as
s
])
...
...
@@ -260,20 +262,21 @@
[
schema
]
(
let
[
schema-type
(
try
(
mc/type
schema
)
(
catch
clojure.lang.ExceptionInfo
_
(
mc/type
#
_
:clj-kondo/ignore
(
eval
schema
))))]
(
condp
=
schema-type
;; can use regex directly
:re
(
first
(
try
(
mc/children
schema
)
(
catch
clojure.lang.ExceptionInfo
_
(
mc/children
#
_
:clj-kondo/ignore
(
eval
schema
)))))
'pos-int?
#
"[0-9]+"
:int
#
"-?[0-9]+"
'int?
#
"-?[0-9]+"
:uuid
u/uuid-regex
'uuid?
u/uuid-regex
nil
)))
(
mc/type
#
_
:clj-kondo/ignore
(
eval
schema
))))]
[
schema-type
(
condp
=
schema-type
;; can use any regex directly
:re
(
first
(
try
(
mc/children
schema
)
(
catch
clojure.lang.ExceptionInfo
_
(
mc/children
#
_
:clj-kondo/ignore
(
eval
schema
)))))
'pos-int?
#
"[0-9]+"
:int
#
"-?[0-9]+"
'int?
#
"-?[0-9]+"
:uuid
u/uuid-regex
'uuid?
u/uuid-regex
nil
)]))
(
def
^
:private
no-regex-schemas
#
{(
mc/type
ms/NonBlankString
)})
(
defn
add-route-param-schema
"Expand a `route` string like \"/:id\" into a Compojure route form with regexes to match parameters based on
...
...
@@ -284,13 +287,18 @@
[
arg->schema
route
]
(
if
(
vector?
route
)
route
(
let
[[
wildcard
&
wildcards
]
(
for
[[
k
schema
]
arg->schema
:when
(
re-find
(
re-pattern
(
str
":"
k
))
route
)
:let
[
re
(
->matching-regex
schema
)]]
(
if
re
[
route
(
keyword
k
)
re
]
(
when
config/is-dev?
(
log/fatal
"Warning: missing route-param regex for schema:"
route
[
k
schema
]))))]
(
let
[[
wildcard
&
wildcards
]
(
for
[[
k
schema
]
arg->schema
:when
(
re-find
(
re-pattern
(
str
":"
k
))
route
)
:let
[[
schema-type
re
]
(
->matching-regex
schema
)]]
(
if
re
[
route
(
keyword
k
)
re
]
(
when
(
and
config/is-dev?
(
not
(
contains?
no-regex-schemas
schema-type
)))
(
log/warn
(
colorize/red
(
str
"Warning: missing route-param regex for schema: "
route
" "
[
k
schema
])))
(
log/warn
(
colorize/green
(
str
"Either add "
(
pr-str
schema-type
)
" to "
"metabase.api.common.internal/->matching-regex or "
"metabase.api.common.internal/no-regex-schemas."
))))))]
(
cond
;; multiple hits -> tack them onto the original route shape.
wildcards
(
reduce
into
wildcard
(
mapv
#
(
drop
1
%
)
wildcards
))
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment