Skip to content

Register .wdl as text MIME type for RStudio (PHP-130724)#332

Open
emmarogge wants to merge 1 commit intomasterfrom
emmarogge/PHP-130724
Open

Register .wdl as text MIME type for RStudio (PHP-130724)#332
emmarogge wants to merge 1 commit intomasterfrom
emmarogge/PHP-130724

Conversation

@emmarogge
Copy link
Contributor

@emmarogge emmarogge commented Mar 3, 2026

Problem

RStudio misidentifies .wdl files containing import statements as binary/JavaScript, preventing users from opening them in the editor. This only affects RStudio — VS Code handles them fine.

Root cause: When .wdl isn't registered as a known MIME type, GIO/libmagic falls back to content-based detection, sees the import keyword, infers JavaScript, and RStudio treats it as non-text.

Fix

Register .wdl as text/x-wdl via the freedesktop shared-mime-info system during post-startup.sh. This ensures extension-based MIME resolution takes priority over content-based detection.

  • Creates /usr/share/mime/packages/wdl.xml with a glob pattern for *.wdl
  • Runs update-mime-database to rebuild the MIME database
  • Only runs when rstudio-server is present, so non-RStudio apps are unaffected

Both r-analysis and r-analysis-aou apps benefit since they both invoke post-startup.sh. Verified that the MIME XML is well-formed and the guard condition correctly scopes to RStudio environments.

Validation Plan

Validation Plan: PHP-130724 — Register .wdl as text MIME type for RStudio

1. CI smoke test (automatic)

  • PR triggers the test-pr.yaml workflow
  • r-analysis smoke test passes
  • r-analysis-aou smoke test passes
  • Non-RStudio app smoke tests (e.g., vscode) still pass

2. Local devcontainer build

  • Build and start the R app locally:
    cd src/r-analysis
    devcontainer up --workspace-folder .
  • Confirm /usr/share/mime/packages/wdl.xml exists in the container:
    devcontainer exec --workspace-folder . /bin/bash -c "cat /usr/share/mime/packages/wdl.xml"

3. MIME resolution check

  • Create a test .wdl file with an import statement inside the container:
    cat > /tmp/main.wdl << 'EOF'
    import "tasks/align.wdl" as align
    workflow main {
      call align.bwa_mem
    }
    EOF
  • Verify xdg-mime query filetype /tmp/main.wdl returns text/x-wdl (not application/javascript)
  • Verify file --mime-type /tmp/main.wdl returns a text/* type

4. RStudio Server UI test

  • Open RStudio Server at localhost:8787
  • Clone the reproducer repo or create a .wdl file with import statements
  • Click on workflows/main.wdl in the RStudio file browser
  • Confirm the file opens in the editor as text (no "binary file" error)
  • Confirm other .wdl files (without import) also still open normally

5. Workbench deployment test

  • Deploy a test r-analysis app in a Workbench workspace using the branch image
  • Open the app and clone a repo with .wdl files
  • Click on main.wdl (the file containing import statements) in the RStudio file browser
  • Verify it opens as text, not as binary

6. Negative testing

  • Confirm post-startup.sh does not create /usr/share/mime/packages/wdl.xml on a VS Code or Jupyter app (the command -v rstudio-server guard should skip it)
  • Verify a VS Code app still starts and functions normally

PHP-130724

RStudio misidentifies .wdl files containing 'import' statements as
binary/JavaScript, preventing users from opening them. Fix by
registering .wdl as text/x-wdl via the freedesktop shared-mime-info
system during post-startup, so extension-based MIME resolution takes
priority over content-based detection.

Only runs when rstudio-server is present, so non-RStudio apps are
unaffected.
@emmarogge emmarogge requested review from kirtanav98 and yuhuyoyo March 3, 2026 18:11
@emmarogge emmarogge marked this pull request as ready for review March 3, 2026 18:39
@emmarogge emmarogge requested review from a team as code owners March 3, 2026 18:39
@emmarogge emmarogge requested a review from moiradillon100 March 3, 2026 18:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants