Repository navigation
fix: restore the contact list by fixing dav template module interop - #794
Merged
Merged
Conversation
The Contacts app loaded but showed no address books and no contacts on
ownCloud 11. Every call into the vendored dav library's request templates
threw "template.propfind is not a function", eight times per page load.
js/dav/lib/template/index.js was CommonJS re-exporting six modules that
are each ESM with a single `export default`:
exports.propfind = require('./propfind');
Under the original babel 5 pipeline a lone default export was collapsed
onto module.exports, so that yielded the function. esbuild - which built
the bundle currently committed - follows the spec instead: require() of
an ESM module yields the namespace object. So template.propfind became
{ default: fn } and every template.X(...) call site in lib/request.js
threw. All six templates were affected: propfind, addressBookQuery,
calendarQuery, syncCollection, mkcol and proppatch, which between them
cover listing, searching, sync, creating an address book and renaming
one - effectively the whole app.
The barrel now re-exports the default bindings explicitly, which is
correct under any bundler and does not depend on babel 5's semantics.
Also make js/dav/dav.js reproducible, because it was not. Rebuilding it
needed three things the repository did not contain:
- shims/xmlhttprequest.js, a one-line browser shim for the node-only
xmlhttprequest package. The committed bundle embeds it from
../../../shims/xmlhttprequest.js - a path outside the repository.
- a locked dependency tree. Runtime dependencies are compiled into the
bundle, so the ^0.8.13 range on @xmldom/xmldom silently made the
artifact float; `url` additionally has to stay at 0.11.0, since 0.11.1+
swap querystring for qs and pull in ~45 further modules. Direct
versions are now exact and package-lock.json is committed, un-ignored
by name in .gitignore.
- the esbuild invocation itself, which was recorded nowhere. 0d133ae
(#775) switched bundlers but left the Makefile describing the babel 5 +
browserify pipeline it had replaced, which is how the bundle came to
drift from its sources undetected.
The Makefile's dav.js target now runs esbuild, `npm ci` builds from the
lockfile, and two consecutive runs produce a byte-identical bundle. Its
dav.min.js target also worked only by accident before: uglify-js 2.x has
an ES5-only parser and cannot read esbuild output at all, so `make` in
js/dav failed on its default goal. It now minifies with esbuild, and
dav.js - the only artifact this repository consumes - is the default
goal.
Rebuilding moves the bundled @xmldom/xmldom from 0.8.13 to 0.8.15, which
accounts for most of the diff in dav.js; it is called out in the
changelog.
Verified against owncloud/server:11.0.0 with the app installed: before,
the address book list is empty and the console carries eight "not a
function" exceptions; after, the address book and its contacts render,
the contact detail form is populated from the vCard, the Rename / Link /
Download / Delete / Import controls appear, and the console is clean.
Confirmed the same esbuild recipe against the unfixed source still
reproduces the fault, so the repair is the source change and not the
rebuild.
Signed-off-by: Thomas Müller <[email protected]>
js/dav/dav.js is a generated artifact that karma already loads, but nothing asserted anything about it, so the interop break in the previous commit passed CI green: the whole app was unusable while every test passed. Adds a spec that builds a propfind, addressBookQuery and syncCollection request and checks the rendered propfind body. Verified as a real gate by running it against the broken bundle, where four of the five cases fail with the production error - "TypeError: template.propfind is not a function" - and against the fixed bundle, where all pass. Signed-off-by: Thomas Müller <[email protected]>
Follow-up to the previous two commits, from reviewing them. - .github/workflows/main.yml: a `dav bundle` job rebuilds js/dav/dav.js and fails if it differs from the committed bundle. The previous commits supply a correct Makefile and a lockfile but no gate, so an edit under js/dav/lib with no rebuild would ship a stale bundle exactly as before. Since the build is byte-reproducible from the lockfile, comparing against the worktree is reliable. Two details matter: the bundle is deleted before the rebuild, so the job cannot pass by having `make` decide nothing was out of date - which is what would happen the moment node_modules gets cached - and the comparison uses `git status --porcelain`, since `git diff` reports neither untracked nor deleted paths and so would call a PR that dropped dav.js from the index "in sync". Verified all three ways: green in sync, red on an edited template, red on a bundle removed from the index. - js/dav/Makefile: `npm ci` instead of `npm install`, with package-lock.json as a prerequisite. Without it, bumping a dependency in the lockfile alone left make thinking dav.js was up to date and the superseded dependency stayed compiled in. `clean` no longer deletes dav.js, which is tracked - it used to remove the bundle the app loads and leave the worktree broken. The minify target uses --sourcemap rather than --sourcemap=external: the latter omits the sourceMappingURL comment, which would orphan the map where the uglify invocation it replaces emitted the link. - js/dav/package.json: drop browserify. Nothing has referenced it since the bundler switch, and it was the largest contributor to the lockfile - removing it takes the lock from 236K to 181K and drops a duplicate punycode. babel stays: test/mocha.opts still uses babel/register. - js/dav/package-lock.json: regenerated clean. The first version carried an extraneous punycode 1.4.1 that `npm install` would delete, so the committed lockfile was not the tree npm considered canonical and a build dirtied the worktree. `npm install` is now idempotent against it. - js/dav/.gitignore: ignore dav.min.js.map, the map's new name. - js/tests/dav_bundle.js: cover the other three templates - mkcol and proppatch, which back creating and renaming an address book, and calendarQuery. All six now fail against the broken bundle and pass against the fixed one. The only change to dav.js is two module-path comments: with the extraneous entry gone, url's punycode 1.3.2 hoists to the top level instead of staying nested. The bundled version is unchanged. Note that `dav bundle` is not yet in the contacts-status-checks ruleset, so it reports but cannot block a merge until owncloud/admin adds it. Signed-off-by: Thomas Müller <[email protected]>
oc-tmueller
force-pushed
the
fix/dav-template-esm-interop
branch
from
September 22, 2026 21:24
8a5c0a0 to
671f1e2
Compare
kw-tmueller
approved these changes
Sep 22, 2026
kw-tmueller
approved these changes
Sep 22, 2026
oc-tmueller
added a commit
that referenced
this pull request
Sep 22, 2026
Cuts 1.6.0, the first release since 1.5.5 (2018-12-11). - CHANGELOG.md: [Unreleased] closed out as [1.6.0], link refs updated - sonar-project.properties: sonar.projectVersion 1.0 -> 1.6.0 - package.json: version 1.5.4 -> 1.6.0, two releases behind appinfo/info.xml needs no change - it already declares 1.6.0, bumped in 5c9b81e along with the min-version/max-version 11 dependency and the PHP 8.3 requirement, but never tagged. The release workflow added by #793 enforces that the tag matches <version>. Dropping ownCloud 10 and PHP < 8.3 gets its own Removed section rather than a bullet in the middle of Changed: it is the one fact in this changelog that can leave an administrator with a disabled app after an upgrade, so it should not be easy to skim past. For the same reason #775 is under Security rather than Fixed - it replaces a bundled XML parser carrying unpatched advisories, and reads as a rename otherwise. The #794 entry says explicitly that the regression it fixes never reached a release. 1.5.5 predates #775 by eight years, so without that note an administrator reading these release notes would conclude their current install has a broken contact list and treat 1.6.0 as urgent. The dependency line names the development toolchain explicitly: every package.json change since 1.5.5 was a devDependency. The one bundled runtime library that does move is @xmldom/xmldom, via #794, and that is called out on its own line. Signed-off-by: Thomas Müller <[email protected]>
oc-tmueller
added a commit
that referenced
this pull request
Sep 23, 2026
Cuts 1.6.0, the first release since 1.5.5 (2018-12-11). - CHANGELOG.md: [Unreleased] closed out as [1.6.0], link refs updated - sonar-project.properties: sonar.projectVersion 1.0 -> 1.6.0 - package.json: version 1.5.4 -> 1.6.0, two releases behind appinfo/info.xml needs no change - it already declares 1.6.0, bumped in 5c9b81e along with the min-version/max-version 11 dependency and the PHP 8.3 requirement, but never tagged. The release workflow added by #793 enforces that the tag matches <version>. Dropping ownCloud 10 and PHP < 8.3 gets its own Removed section rather than a bullet in the middle of Changed: it is the one fact in this changelog that can leave an administrator with a disabled app after an upgrade, so it should not be easy to skim past. For the same reason #775 is under Security rather than Fixed - it replaces a bundled XML parser carrying unpatched advisories, and reads as a rename otherwise. The #794 entry says explicitly that the regression it fixes never reached a release. 1.5.5 predates #775 by eight years, so without that note an administrator reading these release notes would conclude their current install has a broken contact list and treat 1.6.0 as urgent. The dependency line names the development toolchain explicitly: every package.json change since 1.5.5 was a devDependency. The one bundled runtime library that does move is @xmldom/xmldom, via #794, and that is called out on its own line. Signed-off-by: Thomas Müller <[email protected]> Co-authored-by: Thomas Müller <[email protected]>
This was referenced Sep 24, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The bug
On ownCloud 11 the Contacts app loads its shell — "New contact", "All contacts",
"Settings" — and then shows nothing. No address book, no contacts. Every call into
the vendored dav library's request templates throws, eight times per page load:
js/dav/lib/template/index.jswas CommonJS re-exporting six modules that are each ESMwith a single
export default:Under the original babel 5 pipeline a lone default export was collapsed onto
module.exports, so that yielded the function. esbuild — which built the bundlecurrently on
master— follows the spec:require()of an ESM module yields thenamespace object.
template.propfindbecame{ default: fn }, and everytemplate.X(...)call site inlib/request.jsthrew.All six templates were affected —
propfind,addressBookQuery,calendarQuery,syncCollection,mkcol,proppatch— which between them cover listing, searching,sync, creating an address book and renaming one. Effectively the whole app.
Introduced by #775, which migrated the bundled
xmldomto@xmldom/xmldom(a realsecurity fix) and regenerated the bundle with a new bundler.
The fix
The barrel re-exports the default bindings explicitly, which is correct under any
bundler and does not rely on babel 5's semantics. Six lines.
Why the rest of the diff exists
js/dav/dav.jscould not be rebuilt from this repository at all. Reproducing it neededthree things the repo did not contain:
shims/xmlhttprequest.js— a one-line browser shim for the node-onlyxmlhttprequestpackage. The committed bundle embeds it from../../../shims/xmlhttprequest.js, a path outside the repository.^0.8.13range on@xmldom/xmldommade the artifact float.urlmust stay at0.11.0: it is imported byaccounts.js,calendars.js,client.jsandcontacts.js, and 0.11.1+ swapquerystringforqs, pulling in ~45 further modules.Makefile describing the babel 5 + browserify pipeline it had replaced. That gap is
what let the bundle drift from its sources undetected.
So: the shim is committed, direct versions are exact,
package-lock.jsonis committed(un-ignored by name), and the Makefile's
dav.jstarget runs esbuild vianpm ci. Twoconsecutive runs now produce a byte-identical bundle.
A
dav bundleCI job rebuilds the bundle and fails if it differs from what is committed— the check that would have caught this. It deletes the bundle before rebuilding so it
cannot pass by having
makedecide nothing was stale, and compares withgit status --porcelainbecausegit diffreports neither untracked nor deleted paths.makeinjs/davwas also broken independently of this: its default goal runsuglify-js2.x, whose ES5-only parser cannot read esbuild output at all(
Unexpected token: punc ())on line 1). It now minifies with esbuild, anddav.js—the only artifact this repo consumes — is the default goal.
make cleanno longerdeletes
dav.js, which is tracked.Rebuilding moves the bundled
@xmldom/xmldomfrom 0.8.13 to 0.8.15; called out in thechangelog.
Verification
Against
owncloud/server:11.0.0with the app installed and signed:ng-viewcontentThe contact detail form is populated from the vCard (phone, email, structured name), and
occ integrity:check-app contactspasses on a tarball signed with the new G2 certificate— then correctly reports
INVALID_HASHand exits 1 when a signed file is tampered with.I also confirmed the same esbuild recipe against the unfixed source still
reproduces the fault, so the repair is the source change and not the rebuild.
js/tests/dav_bundle.jsguards all six templates. Verified as a real gate, not apassing test: against the broken bundle seven of the eight cases fail with the
production error; against the fixed bundle all pass (21 tests total, karma/Firefox).
Note
dav bundleis not in thecontacts-status-checksruleset, so it reports but cannotblock a merge until
owncloud/adminadds it. Given the whole premise here is that CIstayed green while the app was unusable, that is worth doing.