clj-commons / clj-commons/failjure
Failure spec checking fails for functions returning collections
- Dominant language
- Clojure
- Stars
- 427
- Forks
- 20
- PR merge metrics
- No merged PRs in 30d
Description
examples use defn-spec from orchestra
This works:
```
(defn-spec test-failure-works (s/or :ok string? :fail ::fs/failure)
[]
(f/fail "something wrong"))
```
This does not work --looks like the invocation of 'empty' on Failure record from the clojure.spec code is the problem:
```
(defn-spec test-failure-doesnt-work (s/or :ok (s/coll-of string?) :fail ::fs/failure)
[]
(f/fail "something wrong"))
```
------
Unhandled java.lang.UnsupportedOperationException
Can't create empty: failjure.core.Failure
core.clj: 36 failjure.core.Failure/empty
core.clj: 5187 clojure.core/empty
core.clj: 5181 clojure.core/empty
alpha.clj: 1229 clojure.spec.alpha/every-impl/cfns/fn
alpha.clj: 1243 clojure.spec.alpha/every-impl/reify
alpha.clj: 1017 clojure.spec.alpha/or-spec-impl/fn
alpha.clj: 1052 clojure.spec.alpha/or-spec-impl/reify
alpha.clj: 150 clojure.spec.alpha/conform
alpha.clj: 146 clojure.spec.alpha/conform
test.clj: 97 orchestra.spec.test/spec-checking-fn/conform!
test.clj: 125 orchestra.spec.test/spec-checking-fn/fn
RestFn.java: 397 clojure.lang.RestFn/invoke
Contributor guide
No contributing guide indexed for this repository
Research direction
Reproduce the two defn-spec examples and inspect the reported paths in core.clj, alpha.clj, and test.clj, especially the conforming step in orchestra.spec.test/spec-checking-fn. Compare the scalar and collection-returning cases; done means the collection spec check no longer raises UnsupportedOperationException for a failjure.core.Failure.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- clojure
- Domain
- backend, testing-qa
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100