Skip to content

fix(vocabulary): improve property existence checks and enhance falsy value handling in tests - #1184

Draft
mon7792 wants to merge 2 commits into
accordproject:mainfrom
mon7792:monish/null-vocab-fix
Draft

mon7792 wants to merge 2 commits into
accordproject:mainfrom
mon7792:monish/null-vocab-fix

Conversation

@mon7792

@mon7792 mon7792 commented Apr 20, 2026

Copy link
Copy Markdown
Contributor

Closes #1183

Fix vocabulary term lookup failing when term value is falsy (empty string, 0, false, null)

Changes

  • Use propertyName in d instead of d[propertyName] in vocabulary.js to correctly detect property existence regardless of value
  • Use term !== null && term !== undefined instead of if (term) in vocabularymanager.js to avoid skipping valid falsy terms
  • Add test cases in vocabulary.js and vocabularymanager.js test suites covering falsy vocabulary term values

Flags

  • The if (term) pattern in VocabularyManager caused fallback to a parent/default vocabulary even when the term was explicitly set to an empty string or other falsy value — this is a
    silent correctness bug, not a crash

Screenshots or Video

N/A

Related Issues

  • Issue #

Author Checklist

  • Ensure you provide a DCO sign-off for your commits using the --signoff option of git commit.
  • Vital features and changes captured in unit and/or integration tests
  • Commits messages follow AP format
  • Extend the documentation, if necessary
  • Merging to main from fork:branchname

Two things you need to fill in manually:

  1. Issue number — if there's a GitHub issue tracking this bug, add it to Closes # and Related Issues
  2. DCO sign-off — if your commits don't have --signoff, you'll need to amend them before the PR can be merged

To check if your commit has a sign-off:
git log -1 --format="%B"
If it's missing Signed-off-by:, let me know and I'll help you add it.

term = voc.getTerm(declarationName, propertyName, identifier);
}
if (term) {
if (term !== null && term !== undefined) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
if (term !== null && term !== undefined) {
if (!!term) {

term = voc.getElementTerms(declarationName, propertyName);
}
if (term) {
if (term !== null && term !== undefined) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
if (term !== null && term !== undefined) {
if (!!term) {

}
else {
const property = decl.properties ? decl.properties.find(d => d[propertyName]) : null;
const property = decl.properties ? decl.properties.find(d => propertyName in d) : null;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why change this behaviour? This can have an adverse effect on other consumers of this.

…value handling in tests

- Updated property existence checks in `getTerm` and `getElementTerms` methods to use `propertyName in d` for better accuracy.
- Enhanced falsy value handling in `VocabularyManager` and added comprehensive tests for various scenarios including empty strings, null values, and non-existent properties.
- Added new test cases to ensure correct behavior for properties with falsy values in both `getTerm` and `getTerms` methods.

Signed-off-by: mon7792 <monish7792@gmail.com>
@github-actions

github-actions Bot commented May 7, 2026

Copy link
Copy Markdown
Contributor

This PR is stale because it has been open 15 days with no activity. Remove stale label or comment or this will be closed in 10 days.

@github-actions

Copy link
Copy Markdown
Contributor

This PR is stale because it has been open with no activity. Remove the stale label or comment to keep it active. Only items with maintainer engagement are auto-closed.

@github-actions github-actions Bot added the Stale label Nov 14, 2026
@mira-accord-project

Copy link
Copy Markdown

Thanks for the work on the vocabulary property checks and the falsy-value handling. This draft has been open since April with no activity since, and it has picked up a rebase-sized diff against main. Could you either mark it ready for review with the changes brought up to date, or let us know if you are no longer working on it? If we hear nothing, a maintainer may close it to keep the queue accurate. It can always be reopened or reworked later.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Vocabulary term lookups silently discard valid falsy values (empty string, null)

2 participants