Fix reading form metadata in forms containing multiple meta sections#7141
Fix reading form metadata in forms containing multiple meta sections#7141seadowg merged 5 commits intogetodk:v2026.1.xfrom
Conversation
|
|
||
| TreeElement trueSubmissionElement; | ||
| // Determine the information about the submission... | ||
| SubmissionProfile p = formDef.getSubmissionProfile(); |
There was a problem hiding this comment.
Was this needed here in any way? I can’t really imagine a use case, but maybe I’m missing something.
There was a problem hiding this comment.
To make the change here very explicit, Collect previously allowed the "meta block" to be defined anywhere within the primary instance. This PR changes that so that it's only supported if it is a direct child of the primary instance. Is that your understanding @grzesiek2010?
As far as I can see, the spec is actually a little ambiguous on where the meta block should live. All the examples show it as a direct child, but that requirement isn't really stated explicitly. The closes we get to that is probably:
The primary instance also includes a special type of nodes for metadata inside the block. See the Metadata section
"contains" isn't really specific enough to make this change, but I suspect the intention in the spec is that the meta block should be a direct child. I'd like to get second opinions from @lindsay-stevens or @lognaturel.
There was a problem hiding this comment.
This PR changes that so that it's only supported if it is a direct child of the primary instance. Is that your understanding @grzesiek2010?
Kind of, I mean yes, and that's why I got rid of findDepthFirst function, but here the question was more about using SubmissionProfile. Whether it was needed for something or not.
There was a problem hiding this comment.
As far as I can see, the spec is actually a little ambiguous on where the meta block should live. All the examples show it as a direct child, but that requirement isn't really stated explicitly.
This PR is not the first where we assume the main meta block (with instanceId, instanceName, audit) is the direct child, see:
https://github.com/getodk/collect/blob/master/collect_app/src/main/java/org/odk/collect/android/formmanagement/finalization/EditedFormFinalizationProcessor.kt#L23
There was a problem hiding this comment.
Good point! Ok so if there is a problem with that, it will already exist. I'd still like to hear from others (so we can at least make the spec clearer), but this is good to go.
There was a problem hiding this comment.
Very interesting, I'd never noticed that ambiguity. I assume the original intent was indeed the direct meta child, that's certainly an important assumption for the whole way the multiple Entity declaration spec works. I think we should make the spec more specific.
There was a problem hiding this comment.
I think pyxform is currently doing as expected but I've filed XLSForm/pyxform#831 to improve test coverage. The spec examples show the main meta element being a child of the primary data instance root element (usually data), but it wouldn't hurt to also say that in the text, and perhaps also that any other meta elements (expected for entities) must only have entities in them (though meta isn't currently a reserved name so that might be a stretch).
There was a problem hiding this comment.
Great! I can get a PR up for the spec then.
|
I reproduced the issue using the store version of Collect (2026.1.1) and forms from the forum issue. There's a difference in results when I use test.getodk.cloud and staging.getodk.cloud |
|
@dbemke it shouldn't matter, but I'd definitely not expect the behaviour you're seeing on test. What are the reproduction steps to get in that state with test.getodk.cloud? |
Steps to reproduce:
There are links (above) to user "instancename" both on staging and test. |
|
but I don't know what changes these two servers contain, but it's ok to test this PR only with |
|
@grzesiek2010 @dbemke ah ok my guess is that it's changes to XLSForm that generate a different XForm from the example. @grzesiek2010 could you share the full XForm that should be used for testing just so there's no confusion? @dbemke it'd be worth double-checking that this is indeed an expected change by downloading the XForm you get from the example |
I've downloaded the one from |
|
Tested with success Verified on Android 16
|
|
Tested with success Verified on Android 10 |
Fix reading form metadata in forms containing multiple meta sections

Closes #7138
Why is this the best possible solution? Were any other approaches considered?
This ensures the correct for metadata is always read from the top-level
<meta>, avoiding using other<meta>sections that only contain entity information.How does this change affect users? Describe intentional changes to behavior and behavior that could have accidentally been affected by code changes. In other words, what are the regression risks?
This should only fix the issue. I can't think of any bigger risk here.
Do we need any specific form for testing your changes? If so, please attach one.
The form from https://forum.getodk.org/t/entity-submission-draft-shown-with-form-title-rather-than-instance-name-in-collect/57858
Does this change require updates to documentation? If so, please file an issue here and include the link below.
No.
Before submitting this PR, please make sure you have:
./gradlew connectedAndroidTest(or./gradlew testLab) and confirmed all checks still passDateFormatsTest