Skip to content

Use fes:ResourceId in WFS 2.0.0 transaction filters - #17583

Merged
ahocevar merged 3 commits into
openlayers:mainfrom
sobol-sudo:wfs-2-resourceid-filter
Jul 28, 2026
Merged

ahocevar merged 3 commits into
openlayers:mainfrom
sobol-sudo:wfs-2-resourceid-filter

Conversation

@sobol-sudo

Copy link
Copy Markdown
Contributor

Fixes #16166.

When you write a WFS transaction with version: '2.0.0', the update and delete bodies come out with <Filter><FeatureId fid="..."/></Filter>. That element is WFS 1.x only — 2.0.0 renamed it to ResourceId with an rid attribute, and moved filters into the fes/2.0 namespace. GeoServer rejects the request as an unparsable filter, so writeTransaction doesn't really work against a 2.0.0 server.

writeOgcFidFilter already reads the version into a local but never uses it, so this branches on it the same way writeProperty does a few lines below when it picks between ValueReference and Name. It also switches the namespace lookup from OGCNS[version] to the existing getFilterNS(version) helper — ResourceId only exists in fes/2.0, so renaming the element without that would still produce something GeoServer rejects. getFilterNS is what every other filter-writing function in the file already uses, and for 1.0.0 and 1.1.0 it returns exactly what OGCNS[version] returned, so nothing changes on those versions.

I added a spec next to the existing ValueReference one that writes a 2.0.0 transaction with both an update and a delete, so both call sites are covered, and looks the elements up by namespace rather than by string so the namespace half is actually asserted. It fails on main with no ResourceId elements found. The full browser suite is green at 173 files / 3041 tests, node at 74 / 2217, plus lint and both typechecks.

One thing I left alone: the read side has the same gap, since OGC_FID_PARSERS only knows FeatureId, so 2.0.0 TransactionResponse insert results don't parse. Happy to do that separately if you want it.

@github-actions

Copy link
Copy Markdown

@ahocevar ahocevar left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for addressing this, @sobol-sudo. The change looks good. For the test to be less bloated, I'd prefer if you'd address the read side as well and do a clean round-trip test instead.

Comment thread test/browser/spec/ol/format/wfs.test.js Outdated
Comment on lines +2136 to +2146
const resourceIds = serialized.getElementsByTagNameNS(
'http://www.opengis.net/fes/2.0',
'ResourceId',
);
assert.lengthOf(resourceIds, 2);
for (const resourceId of resourceIds) {
assert.strictEqual(resourceId.getAttribute('rid'), '12345');
}
const xmlString = new XMLSerializer().serializeToString(serialized);
assert.notInclude(xmlString, 'FeatureId');
assert.notInclude(xmlString, 'fid=');

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests would look nicer if you'd fix the read side as well, because then a round trip with a single assertXmlEqual() could replace all these lines.

@sobol-sudo

Copy link
Copy Markdown
Contributor Author

Done — read side is in, and the test is now a single round-trip.

OGC_FID_PARSERS only knew FeatureId in the two ogc namespaces, so a 2.0.0 TransactionResponse came back with an empty insertIds. Added the fes/2.0 / ResourceId / rid entry next to them.

The spec now writes a 2.0.0 transaction, takes the ResourceId element the writer actually produced, drops it into a TransactionResponse and reads it back, asserting insertIds is ['12345']. No string matching left, and it covers both halves at once — with only the write side fixed it fails with expected [] to deeply equal [ '12345' ].

Browser suite is green apart from renderer/webgl/VectorLayer "does not call layer.changed() if the renderer was disposed in the meantime", which is flaky here rather than related — it passed in the run before this one and passes three times in a row on its own. Node suite, lint and both typechecks are clean.

@ahocevar ahocevar left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, my bad about round-trip — not ideal here because of the "Transaction"/"TransactionResponse" asymmetry. I split the test into two, and now I think they are much easier to read.

Thanks, @sobol-sudo

@ahocevar
ahocevar merged commit f12cce7 into openlayers:main Jul 28, 2026
8 checks passed
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.

Using version 2.0.0 of WFS, for a transaction, the WFS format writes filters filtering on FeatureId, whereas WFS 2.0.0 should be using ResourceID

2 participants