Bug
WilcoBundleFinder.find(path, all=False) returns "" (empty string) when no file matches. This breaks Django's staticfiles.finders.find() aggregation.
Root cause
In wilco/bridges/django/finders.py, lines 55 and 69:
Django's finders.find() iterates all finders and collects results:
for finder in get_finders():
result = finder.find(path, all=all)
if not all and result:
return result
if not isinstance(result, (list, tuple)):
result = [result]
matches.extend(result)
if matches:
return matches
return [] if all else None
When all=False, the "" is falsy so it doesn't trigger early return. But then it gets wrapped into [""] and added to matches. Since [""] is truthy, finders.find() returns [""] instead of None.
Impact
Any middleware or tool that calls finders.find() receives [""] (a list) instead of None for non-wilco paths. For example, whitenoise 6.x calls finders.find() and then passes the result to os.path.exists(), which raises:
TypeError: stat: path should be string, bytes, os.PathLike or integer, not list
This only manifests when a static file is not found by any other finder (e.g. a hashed filename in development mode).
Suggested fix
Return None instead of "" when all=False:
# finders.py, line 55 and 69
return [] if all else None
This matches the convention used by Django's built-in finders (FileSystemFinder, AppDirectoriesFinder) which return the empty matches list for no-match with all=False, or a string path on match.
Bug
WilcoBundleFinder.find(path, all=False)returns""(empty string) when no file matches. This breaks Django'sstaticfiles.finders.find()aggregation.Root cause
In
wilco/bridges/django/finders.py, lines 55 and 69:Django's
finders.find()iterates all finders and collects results:When
all=False, the""is falsy so it doesn't trigger early return. But then it gets wrapped into[""]and added tomatches. Since[""]is truthy,finders.find()returns[""]instead ofNone.Impact
Any middleware or tool that calls
finders.find()receives[""](a list) instead ofNonefor non-wilco paths. For example, whitenoise 6.x callsfinders.find()and then passes the result toos.path.exists(), which raises:This only manifests when a static file is not found by any other finder (e.g. a hashed filename in development mode).
Suggested fix
Return
Noneinstead of""whenall=False:This matches the convention used by Django's built-in finders (
FileSystemFinder,AppDirectoriesFinder) which return the emptymatcheslist for no-match withall=False, or a string path on match.