review: `read-attributes`, `read-attributes*` fns `attributes` arg
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 48/100
- Issue type
- Documentation
- Clarity
- Mostly clear
- Activity status
- Quiet
- Domain
- documentation
Research direction
Start in fs.cljc around line 917 and read the read-attributes and read-attributes* entry points. Decide which attributes argument types and return values are supported, then document that behavior for both functions; done means the documented contract matches the observed Clojure and JDK behavior.
Written by the indexing model from the issue text.
Description
Issue
read-attributes is a clojure-friendly version of read-attributes*.
But... while read-attributes will accept a class for attributes arg, read-attributes* will fail if this is done.
Repro
Setup:
(require '[babashka.fs :as fs])
(spit "foo" "foo")
I can get the basic file attributes with read-file-attributes* via class, like so:
(fs/read-attributes* "foo" java.nio.file.attribute.BasicFileAttributes)
;; => #object[sun.nio.fs.UnixFileAttributes$UnixAsBasicFileAttributes 0x7f082a4b "sun.nio.fs.UnixFileAttributes$UnixAsBasicFileAttributes@7f082a4b"]
The equivalent via string attributes:
(fs/read-attributes* "foo" "basic:*")
;; => {"lastAccessTime" #object[java.nio.file.attribute.FileTime 0x815f84b "2026-04-13T15:15:36.252890688Z"], "lastModifiedTime" #object[java.nio.file.attribute.FileTime 0x72ee0f3d "2026-04-13T15:15:36.252890688Z"], "size" 3, "creationTime" #object[java.nio.file.attribute.FileTime 0x335df4df "2026-04-13T15:15:36.252890688Z"], "isSymbolicLink" false, "isRegularFile" true, "fileKey" #object[sun.nio.fs.UnixFileKey 0x2434f0ef "(dev=802,ino=20868808)"], "isOther" false, "isDirectory" false}
(notice the return value changes to map when fetching via string, this is an underlying JDK API thing).
Now when I move to read-attributes, I can use a string attribute:
(fs/read-attributes "foo" "basic:*")
;; => {:creationTime
;; #object[java.nio.file.attribute.FileTime 0x4e91e01e "2026-04-13T15:15:36.252890688Z"],
;; :isSymbolicLink false,
;; :isOther false,
;; :lastAccessTime
;; #object[java.nio.file.attribute.FileTime 0x592c0ff5 "2026-04-13T15:15:36.252890688Z"],
;; :isRegularFile true,
;; :size 3,
;; :lastModifiedTime
;; #object[java.nio.file.attribute.FileTime 0x6bd67295 "2026-04-13T15:15:36.252890688Z"],
;; :fileKey #object[sun.nio.fs.UnixFileKey 0xa637dac "(dev=802,ino=20868808)"],
;; :isDirectory false}
But... when I try read-attributes with a class attribute, it fails:
(fs/read-attributes "foo" java.nio.file.attribute.BasicFileAttributes)
;; => Execution error (IllegalArgumentException) at babashka.fs/read-attributes (fs.cljc:917).
;; Don't know how to create ISeq from: sun.nio.fs.UnixFileAttributes$UnixAsBasicFileAttributes
Observation
Neither read-attributes nor read-attributes* mentions supported types for attributes args, but the implementation supports both string and class variants.
I guess that most folks would pass in a string attribute? It seems the more clojure-friendly option.
As for the differing return values, would a bb fs user ever prefer/need the class variant that the class attribute returns over the map that basic:* returns?
Option 0: Do nothing
Assume folks will be using string attributes.
Pros:
- no work for us
Cons:
- unclear for users
Option 1: Document read-attributes and read-attributes* accept string attributes arg
Leave the class attributes args as an undocumented/unsupported feature.
Pros:
- documents common/recommended use case
Option 2: Document attributes arg types and returns for read-attributes* and read-attributes
For read-attributes this would mean documenting that we only suport a string attributes arg.
For read-attributes* this would mean documenting string and class attributes arg. And their effect on return value type.
Pros:
- describes implementations
Cons:
- more to read/understand for users
Option 3: Support class attributes arg for read-attributes
Pros:
- Symmetry
read-attributes*andread-attributes
Cons:
- I don't think this would be easy, as I don't see JDK support for conversion.
Proposal
If we assume that bb fs users would prefer to specify attributes as a string and have no real need for a class version of attributes (over the map variant), then I think Option 1: doc string attributes arg only makes sense.
What do you think?
- Dominant language
- Clojure
- Stars
- 221
- Forks
- 52
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from babashka/fs
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
-
Difficulty 5/5 Over a week Newbie friendliness 30/100
-
`copy-tree`, when following links, does not copy contents of symbolicly linked sub-dirPossibly taken @shivampwm2020 claimed this 51 days ago. Open
Difficulty 3/5 1-2 days Newbie friendliness 35/100
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
-
Difficulty 5/5 Over a week Newbie friendliness 30/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
nextjournal/clerk#830 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
IOP tokens release blocker team qa team qa autotests WG adoption
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
penpot/penpot#13540 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
izhangzhihao/intellij-rainbow-brackets#2903 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 67/100