Repository navigation
Description
Summary
OpenCloud's WebDAV layer resolves a file's MIME type via reva's
pkg/mime/mime.go, specifically the mime.Detect() function
(github.com/opencloud-eu/reva/v2, confirmed against v2.46.6, the version pinned by
opencloudeu/opencloud-rolling:7.2.0). That function does this, in order:
func Detect(isDir bool, fn string) string {
if isDir {
return defaultMimeDir
}
ext := strings.ToLower(strings.TrimPrefix(path.Ext(fn), "."))
mimeType := getCustomMime(ext) // checks a runtime sync.Map — see below
if mimeType == "" {
mimeType = mimeTypes[ext] // checks a large COMPILED-IN static map
}
if mimeType == "" {
mimeType = "application/octet-stream"
}
return mimeType
}The compiled-in mimeTypes map (a large literal map[string]string in the same file)
has entries for the legacy binary Visio family:
"vsd": "application/vnd.visio",
"vss": "application/vnd.visio",
"vst": "application/vnd.visio",
"vsw": "application/vnd.visio",but no entries at all for the modern OOXML-based Visio formats introduced with
Office 2013 (.vsdx, .vsdm, .vssx, .vssm, .vstx, .vstm). There is a
getCustomMime() / mime.RegisterMime(ext, mime string) pair that stores overrides in
a package-level sync.Map — in principle a clean extension point — but nothing in
either opencloud-eu/opencloud or opencloud-eu/reva calls RegisterMime (confirmed
via GitHub code search across both repos). It is unreachable dead code from an
operator's perspective: there is no config file, env var, or CLI flag that drives it.
This is a different and more fundamental gap than it first appears: it is easy to
assume (as this project initially did) that /etc/mime.types on the container's
filesystem is the resolution mechanism, because Go's mime stdlib package does
support reading that file and the string /etc/mime.types does appear in the compiled
opencloud binary (pulled in transitively by some other dependency's use of Go's mime
stdlib). But OpenCloud/reva's own WebDAV mimetype resolution does not go through Go's
mime stdlib at all for this path — it uses reva's own hand-maintained static table.
Editing/mounting /etc/mime.types has no effect on this resolution path. (Verified:
see "How this was verified" below.)
As a result, even after correctly registering the expected Visio content type in
app-registry.yaml:
- mime_type: application/vnd.ms-visio.drawing.main+xml
extension: vsdx
name: Visio Drawing
default_app: OnlyOffice
allow_creation: falseuploading a genuine .vsdx file and opening it via the app-open (WOPI) flow fails,
because the file's detected MIME type is application/octet-stream, which has no
app-registry entry — the file never reaches the app-registry's routing logic at all.
Steps to reproduce
- Bring up OpenCloud (
opencloudeu/opencloud-rolling:7.2.0tested) with an
app-registry entry mappingapplication/vnd.ms-visio.drawing.main+xml→ an
OnlyOffice/WOPI-capable app for thevsdxextension. - Upload any valid
.vsdxfile via WebDAVPUT(tested both a hand-built minimal OOXML
.vsdxand a genuine third-party sample verified withfile(1)as
Microsoft Visio 2013+). PROPFINDthe uploaded file forgetcontenttype.- Observed:
application/octet-stream - Expected:
application/vnd.ms-visio.drawing.main+xml(the OOXML content type
Microsoft's own spec assigns, and the same value[Content_Types].xmlinside the
.vsdxzip declares for the root part)
- Observed:
POST /app/open?file_id=<id>&app_name=OnlyOffice(or open via the web UI).- Observed:
500 SERVER_ERROR: "Error contacting the requested application, please use a different one or try again later" - Expected: WOPI
CheckFileInfoflow proceeds, opening the file (view-only is
fine — OnlyOffice Docs CE's Diagram Viewer is view-only).
- Observed:
How this was verified (ruling out /etc/mime.types and confirming the real cause)
- Uploaded the same file bytes under three different extensions and PROPFIND'd
getcontenttypefor each:.vsdx→application/octet-stream; renamed to.zip→
application/zip(correct —.zipis one of the ~15 extensions Go'smimestdlib
hardcodes as built-in, independent of any file, which is a red herring that briefly
suggested Go's stdlib mime package was in play); renamed to an unregistered extension
(.foobar123) →application/octet-stream(expected negative control). - Mounted a corrected
/etc/mime.types(stock file + the six missing Visio OOXML
entries) into theopencloudcontainer at the real/etc/mime.typespath, confirmed
byte-for-byte viamd5suminside the container, restarted the container, re-uploaded
fresh —.vsdxstill resolved toapplication/octet-streamand/app/openstill
500'd identically. This is what ruled out/etc/mime.typesas the resolution
mechanism for this code path. - Confirmed via GitHub code search (
opencloud-eu/opencloud,opencloud-eu/reva) that
the running version's dependency isgithub.com/opencloud-eu/reva/v2 v2.46.4-0.20260625152426-8cff2a7032ec(pergo.mod), matching the
github.com/opencloud-eu/reva/[email protected]seen in this build's own log lines, and
fetchedpkg/mime/mime.gofrom that repo directly — confirming the static map, the
.vsd/.vss/.vst/.vswentries, the absence of any.vsdx-family entry, and the
unusedRegisterMimefunction described above. - Confirmed no existing upstream issue mentions
vsdxorvisioin either repo
(searched via GitHub's issue search) as of this writing.
Suggested fix (any of)
- Add the six missing entries to the compiled-in
mimeTypesmap in
reva/pkg/mime/mime.go:(This is the minimal, surgical fix — same pattern as the existing legacy entries.)"vsdx": "application/vnd.ms-visio.drawing.main+xml", "vsdm": "application/vnd.ms-visio.drawing.macroEnabled.main+xml", "vssx": "application/vnd.ms-visio.stencil.main+xml", "vssm": "application/vnd.ms-visio.stencil.macroEnabled.main+xml", "vstx": "application/vnd.ms-visio.template.main+xml", "vstm": "application/vnd.ms-visio.template.macroEnabled.main+xml",
- Wire up the already-present-but-unused
mime.RegisterMime()to a real config
surface — e.g. read extension→MIME overrides from a YAML file (analogous to
app-registry.yaml) at OpenCloud startup and callRegisterMimefor each entry.
This would let downstream operators fix gaps like this one (and any future ones)
without needing a fork/rebuild, and is more valuable than fix build(deps-dev): bump dotenv from 16.4.5 to 16.4.7 in /services/idp #1 alone since it
generalizes. - At minimum, document in OpenCloud's own docs that MIME-type resolution for
WebDAV/app-registry purposes is NOT governed by/etc/mime.typesinside the
container (despite that file being present and looking like the obvious place to
look) — this would have saved real debugging time.
Workaround in use (timocloud)
None at the deploy layer — confirmed no config/compose-mountable fix exists (see
above). Per the design's own stated fallback (design doc §13): Visio files show
icon+download only in v1. A real fix (patching reva/pkg/mime/mime.go and rebuilding a
custom OpenCloud image, or waiting for/contributing suggested-fix #1 or #2 above
upstream) is a Phase 1/2 backlog item, not a Phase-0 blocker.
Activity