8000 Forms: make conflation of published/draft explicit by alxndrsn · Pull Request #1527 · getodk/central-backend · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Forms: make conflation of published/draft explicit #1527

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 77 commits into
base: master
Choose a base branch
from

Conversation

alxndrsn
Copy link
Contributor
@alxndrsn alxndrsn commented Jun 17, 2025

TODO

  • make tests pass
  • reverse order of xml, version args
  • rename NoDefRequired to WithoutDef
  • general tidy-up
  • consider defaulting to lowest-cost option (WithoutDef)
  • consider simpler PRs which can come out of this
    • explicit request for PublishedVersion in non-/draft forms API

Current master allows requests for forms through query functions to implicitly conflate form drafts and published versions.

This leads to surprising behaviours in the API like:

Affected functions: pretty much all form querying functions.

Closes #

What has been done to verify that this works as intended?

Why is this the best possible solution? Were any other approaches considered?

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?

Does this change require updates to the API documentation? If so, please update docs/api.yaml as part of this PR.

Before submitting this PR, please make sure you have:

  • run make test and confirmed all checks still pass OR confirm CircleCI build passes
  • verified that any code from external sources are properly credited in comments or that everything is internally sourced

Current `master` allows requests for forms through query functions to
implicitly conflate form drafts and published versions.

This leads to surprising behaviours in the API like:

* getodk#1404
* TODO others?

Affected functions: pretty much all form querying functions.
@@ -22,6 +24,12 @@ const Option = require('../../util/option');
const Problem = require('../../util/problem');
const { PURGE_DAY_RANGE } = require('../../util/constants');

const describe = m => (typeof m === 'object' ? JSON.stringify(m) : m);
const fatalError = (...message) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

revert these

@@@@@@ _getSql() @@@@@@
${require('node:util').inspect(query)}
@@@@@@@@@@@@@@@@@@@@@@@
`);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

remove

@@ -3,6 +3,7 @@ const appRoot = require('app-root-path');
const should = require('should');
const { testService } = require('../../setup');
const testData = require('../../../data/xml');
const { getOrNotFound } = require(appRoot + '/lib/util/promise');
Copy link
Contributor Author

Choose a reason for hiding this comment

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

revert

@@ -2021,7 +2020,7 @@ describe('Entities API', () => {

const logger = (action, actee, details) => log(containerTx1.context.auth.actor, action, actee, details);

const entity = await getById(dataset.id, '12345678-1234-4123-8234-123456789abc', QueryOptions.forUpdate)(containerTx1).then(getOrNotFound);
const entity = await getById(dataset.id, '12345678-1234-4123-8234-123456789abc', QueryOptions.forUpdate)(containerTx1).then((o) => o.get());
Copy link
Contributor Author

Choose a reason for hiding this comment

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

re-revert - leave this to the dedicated PR

@@ -1224,7 +1225,7 @@ describe('api: /projects/:id/forms (create, read, update)', () => {
.set('Content-Type', 'application/xml')
.expect(200)
.then(() => service.login('chelsea', (asChelsea) =>
asChelsea.get('/v1/projects/1/forms/withAttachments/attachments')
asChelsea.get('/v1/projects/1/forms/withAttachments/draft/attachments')
Copy link
Contributor Author

Choose a reason for hiding this comment

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

separate PR?

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.

1 participant
0