Skip to content

[feature] Delete data values that belong to given data elements#95

Open
nshandra wants to merge 8 commits intodevelopmentfrom
feat/delete-values-by-de
Open

[feature] Delete data values that belong to given data elements#95
nshandra wants to merge 8 commits intodevelopmentfrom
feat/delete-values-by-de

Conversation

@nshandra
Copy link
Contributor

@nshandra nshandra commented Jan 30, 2026

📌 References

Issue: create (or reuse) a script to delete all data for a list of data elements for all periods and org units

📝 Implementation

Bulk delete data values that belong to the DEs in the provided CSV. This file is expected to be single column with header id.

It splits the provided DEs in chunks of 200 (to not hit the url limit), retrieves limitamount of dataValues and posts them with DELETE strategy. Repeats untill no more data is retrieved and starts with the next DEs block.

The deleted values can be optionally stored in backup files.

#869bxqbjw

@nshandra nshandra requested a review from MiquelAdell January 30, 2026 10:22
@nshandra nshandra self-assigned this Jan 30, 2026
@MiquelAdell
Copy link
Contributor

  • after runing, on the branch
nvm use
yarn
yarn build

I'm getting:

 yarn start datavalues bulk-delete --url='https://dev.user:password@dev.eyeseetea.com/who-dev-41' dataElements.csv 
yarn run v1.22.22
$ node dist/index.js datavalues bulk-delete '--url=https://dev.user:password@dev.eyeseetea.com/who-dev-41' dataElements.csv
node:internal/errors:496
    ErrorCaptureStackTrace(err);
    ^

TypeError [ERR_INVALID_URL]: Invalid URL
    at new NodeError (node:internal/errors:405:5)
    at new URL (node:internal/url:676:13)
    at p (/Users/miqueladell/code/d2-tools/dist/index.js:1:266140)
    at t.getD2Api (/Users/miqueladell/code/d2-tools/dist/index.js:1:266528)
    at Object.handler (/Users/miqueladell/code/d2-tools/dist/index.js:1:230212)
    at Object.run (/Users/miqueladell/code/d2-tools/node_modules/cmd-ts/dist/cjs/command.js:150:41)
    at async Object.run (/Users/miqueladell/code/d2-tools/node_modules/cmd-ts/dist/cjs/subcommands.js:149:32)
    at async Object.run (/Users/miqueladell/code/d2-tools/node_modules/cmd-ts/dist/cjs/subcommands.js:149:32)
    at async runSafely (/Users/miqueladell/code/d2-tools/node_modules/cmd-ts/dist/cjs/runner.js:38:24)
    at async run (/Users/miqueladell/code/d2-tools/node_modules/cmd-ts/dist/cjs/runner.js:10:20) {
  input: 'https://dev.user:password@dev.eyeseetea.com/who-dev-41',
  code: 'ERR_INVALID_URL'
}

Node.js v18.20.8
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Is there something I'm missing?

  • can we have a dry run option? and make that default?
    Check how other d2-tools do that if possible for consistency

  • I was getting an error on some passwords with some characters. I fixed it by singlequoting the url instead of doble quoting it
    can you please update that on the readme?

thanks!

@nshandra
Copy link
Contributor Author

@MiquelAdell Regarding the url param, i switched to a url and auth method that works better with real, complex passwords.
I suspect the error stack you posted is also caused by the old auth method.

Sorry for that.

@MiquelAdell MiquelAdell requested a review from tokland February 2, 2026 12:03
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