Skip to content

.vsdx and other OOXML Visio types resolve to application/octet-stream, breaking WOPI app-open — no config-driven way to add the mapping #3120

Closed
opencloud-eu/reva
#900

Description

@puredomain

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: false

uploading 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

  1. Bring up OpenCloud (opencloudeu/opencloud-rolling:7.2.0 tested) with an
    app-registry entry mapping application/vnd.ms-visio.drawing.main+xml → an
    OnlyOffice/WOPI-capable app for the vsdx extension.
  2. Upload any valid .vsdx file via WebDAV PUT (tested both a hand-built minimal OOXML
    .vsdx and a genuine third-party sample verified with file(1) as
    Microsoft Visio 2013+).
  3. PROPFIND the uploaded file for getcontenttype.
    • 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].xml inside the
      .vsdx zip declares for the root part)
  4. 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 CheckFileInfo flow proceeds, opening the file (view-only is
      fine — OnlyOffice Docs CE's Diagram Viewer is view-only).

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
    getcontenttype for each: .vsdx → application/octet-stream; renamed to .zip →
    application/zip (correct — .zip is one of the ~15 extensions Go's mime stdlib
    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 the opencloud container at the real /etc/mime.types path, confirmed
    byte-for-byte via md5sum inside the container, restarted the container, re-uploaded
    fresh — .vsdx still resolved to application/octet-stream and /app/open still
    500'd identically. This is what ruled out /etc/mime.types as the resolution
    mechanism for this code path.
  • Confirmed via GitHub code search (opencloud-eu/opencloud, opencloud-eu/reva) that
    the running version's dependency is github.com/opencloud-eu/reva/v2 v2.46.4-0.20260625152426-8cff2a7032ec (per go.mod), matching the
    github.com/opencloud-eu/reva/[email protected] seen in this build's own log lines, and
    fetched pkg/mime/mime.go from that repo directly — confirming the static map, the
    .vsd/.vss/.vst/.vsw entries, the absence of any .vsdx-family entry, and the
    unused RegisterMime function described above.
  • Confirmed no existing upstream issue mentions vsdx or visio in either repo
    (searched via GitHub's issue search) as of this writing.

Suggested fix (any of)

  1. Add the six missing entries to the compiled-in mimeTypes map in
    reva/pkg/mime/mime.go:
    "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",
    (This is the minimal, surgical fix — same pattern as the existing legacy entries.)
  2. 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 call RegisterMime for 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.
  3. At minimum, document in OpenCloud's own docs that MIME-type resolution for
    WebDAV/app-registry purposes is NOT governed by /etc/mime.types inside 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions