fix: improve error message for wrongly formatted history files#1248
Conversation
|
Hi @Bhavysinghal and thank you for this contribution! |
8bb29a5 to
9db1386
Compare
|
Hi @MattiSG! I've addressed the bot issues:
The remaining test failures appear to be pre-existing CI infrastructure issues related to Puppeteer/Chrome not being available in the CI environment, and seem unrelated to this change. Please let me know if anything else needs to be addressed! |
9db1386 to
974da05
Compare
|
Hi @MattiSG! I've addressed the bot issues:
The remaining test failures ( The latest commit also needs workflow approval to run — could you please approve it when you have a moment? Thanks again for your guidance! 🙂 |
|
Hey @Bhavysinghal, thank you for handling these! And thank you for having handled even the changelog. Don't sweat it if there are further problems on that part, we'll take care of the changelog bit 🙂 Sorry for not having re-run workflows, I thought once approved they'd run automatically again. I agree with you that the errors outlining a missing browser are not related to your changes. We'll need to investigate that further. @Ndpnt do you think the CI failures could be related to GitHub Actions safety for third party forks? |
|
@MattiSG Nope, these failures are not related to this PR. They’re directly tied to Puppeteer. Rebasing this branch onto the latest engine version (13.0.0) should fix the issue. |
|
Thank you @Ndpnt for your quick reply! @Bhavysinghal are you comfortable with a rebase, or would you need assistance for that? |
974da05 to
d24e62f
Compare
|
Thank you @Bhavysinghal! You're all good on your side at this stage 🙂 |
MattiSG
left a comment
There was a problem hiding this comment.
This works perfectly!
Tested locally, with:
- No history file: no change.
- Properly formatted history file: no change.
- Improperly formatted history file: the error message changes, see below.
engine [main]
› npm run declarations:validate
> @opentermsarchive/engine@13.0.0 declarations:validate
> node bin/ota.js validate declarations
1) Uncaught error outside test suite
0 passing (1ms)
1 failing
1) Uncaught error outside test suite:
Uncaught TypeError: serviceHistory[termsType].push is not a function
→
engine [pr]
› npm run declarations:validate
> @opentermsarchive/engine@13.0.0 declarations:validate
> node bin/ota.js validate declarations
1) Uncaught error outside test suite
0 passing (1ms)
1 failing
1) Uncaught error outside test suite:
Uncaught Error: History file for "Terms of Service" is not properly formatted: expected an array but got an object. Please use [] instead of {}.
|
Thank you very much @Bhavysinghal for your contribution and your patience through this process! We are glad to see this improvement land in main, the history file is one of the harder aspects of working with Open Terms Archive and we regularly received questions regarding that error. This will hopefully ease the contribution process! @all-contributors add @Bhavysinghal for code |
|
Thank you so much @MattiSG for your guidance throughout this process! |
Fixes #1184
What this does
When a history file is formatted incorrectly (using
{}object insteadof
[]array), the engine previously threw a confusing error:"serviceHistory(termsType) push is not a function"
This change adds a validation check that throws a clear, human-readable
error message instead, telling the contributor exactly what is wrong and
how to fix it.
Why
As reported in issue #1184, this confusing error message caused confusion
for contributors. A clear error message will help future contributors
immediately understand and fix their mistake.