Skip to content

Fix Mandatory Attribute Validation#393

Merged
steiler merged 5 commits intosdcio:mainfrom
markafarrell:fix/validate-mandatory-key
Feb 10, 2026
Merged

Fix Mandatory Attribute Validation#393
steiler merged 5 commits intosdcio:mainfrom
markafarrell:fix/validate-mandatory-key

Conversation

@markafarrell
Copy link
Contributor

@markafarrell markafarrell commented Jan 29, 2026

What?

  • Support checking if mandatory attributes are keys
  • Only treat a container as a Choice if it actually is a choice

Why?

  • Without this if a key attribute is marked as mandatory then validation will fail
  • If we try to treat a container as one but it is not (i.e. s.schema.GetContainer().GetChoiceInfo() returns null) then we will have a null pointer dereference error when running GetChoiceByName(c.Name)
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x28 pc=0x1698927]

goroutine 705 [running]:
github.com/sdcio/sdc-protos/sdcpb.(*ChoiceInfo).GetChoiceByName(...)
	/home/runner/go/pkg/mod/github.com/sdcio/sdc-protos@v0.0.46/sdcpb/choice_info_additions.go:4
github.com/sdcio/data-server/pkg/tree.(*sharedEntryAttributes).validateMandatory(0xc0005c1810, {0x1f92800, 0xc000e93b90}, 0xc000b5ad90, 0xc000e8ab38)
	/home/runner/work/data-server/data-server/pkg/tree/sharedEntryAttributes.go:1378 +0x4c7
github.com/sdcio/data-server/pkg/tree.(*sharedEntryAttributes).Validate(0xc0005c1810, {0x1f92800, 0xc000e93b90}, 0xc000b5ad90, 0xc000e8ab38, 0xc000433e50)
	/home/runner/work/data-server/data-server/pkg/tree/sharedEntryAttributes.go:979 +0xa6
github.com/sdcio/data-server/pkg/tree.(*sharedEntryAttributes).Validate.func1({0x1fae540?, 0xc0005c1810?})
	/home/runner/work/data-server/data-server/pkg/tree/sharedEntryAttributes.go:1013 +0x44
created by github.com/sdcio/data-server/pkg/tree.(*sharedEntryAttributes).Validate in goroutine 441
	/home/runner/work/data-server/data-server/pkg/tree/sharedEntryAttributes.go:1017 +0x43a

@markafarrell markafarrell changed the title Fix Mandatory Attribute Validation Draft: Fix Mandatory Attribute Validation Jan 29, 2026
@markafarrell markafarrell marked this pull request as draft January 29, 2026 04:19
@markafarrell markafarrell changed the title Draft: Fix Mandatory Attribute Validation Fix Mandatory Attribute Validation Jan 29, 2026
@steiler
Copy link
Collaborator

steiler commented Jan 29, 2026

@markafarrell yes this seems valid and correct.
Is there more comming regarding this topic or why is the PR just a draft?

@markafarrell
Copy link
Contributor Author

@markafarrell yes this seems valid and correct.
Is there more comming regarding this topic or why is the PR just a draft?

I wanted to add a test case to validate the change before I set the PR to ready.

@markafarrell markafarrell marked this pull request as ready for review February 1, 2026 22:50
@markafarrell markafarrell force-pushed the fix/validate-mandatory-key branch from a988d12 to ec35eb4 Compare February 1, 2026 22:55
@markafarrell
Copy link
Contributor Author

@steiler This is ready for review now

@steiler
Copy link
Collaborator

steiler commented Feb 3, 2026

@markafarrell can you take a look at the ygot struct... it contains an ipv6 container, which is not present in the yang definition.
So I assume you need to rerun building the ygot structs from the sdcio test schema.

@markafarrell
Copy link
Contributor Author

@markafarrell can you take a look at the ygot struct... it contains an ipv6 container, which is not present in the yang definition.
So I assume you need to rerun building the ygot structs from the sdcio test schema.

It is from https://github.com/sdcio/data-server/blob/main/tests%2Fschema%2Fsdcio_model_static_route.yang which was added 3 months ago.

I guess when it was added the ygot make target wasn't run.

I couldn't figure out an elegant way of excluding it.

@steiler
Copy link
Collaborator

steiler commented Feb 3, 2026

@markafarrell can you take a look at the ygot struct... it contains an ipv6 container, which is not present in the yang definition.
So I assume you need to rerun building the ygot structs from the sdcio test schema.

It is from https://github.com/sdcio/data-server/blob/main/tests%2Fschema%2Fsdcio_model_static_route.yang which was added 3 months ago.

I guess when it was added the ygot make target wasn't run.

I couldn't figure out an elegant way of excluding it.

Alright, yes sorry, I see.
So we've missed to update the model back then, since the tests where not specifically using the ygot struct.

Copy link
Collaborator

@steiler steiler left a comment

Choose a reason for hiding this comment

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

lgtm

@markafarrell
Copy link
Contributor Author

lgtm

@steiler Do I need to worry about failing CI?

@steiler
Copy link
Collaborator

steiler commented Feb 6, 2026

lgtm

@steiler Do I need to worry about failing CI?

No, the ci is not to be trusted atm. We've encountered issues with the deviation processing, which was finally revealed by the failing integration tests, so we're changing that processing atm. Having a multi repo project with config-server and data-server in separate repos as well as the integration tests also adds some glitches in this case.
The prs for this are kind of ready, just waiting for approval to merge.
So when that's done, we will have 90 percent back on track. The last thing to tackle is then the capability of manually reverting non-revertive intents. Which the tests cover but need to be brought back in thhat new mode of operation.
Ill run the required tests manually. But I'm off still until Monday. Sorry!

@steiler
Copy link
Collaborator

steiler commented Feb 9, 2026

OK, so I took a closer look and discovered, that even the unittests where failing which should not have happened.
I discovered that in the afore mentioned PR, the schema, precisely the doublekey element was changed so contain a pattern.
This is only failing now, because it was missed to update the ygot schema struct as mentioned before as part of that PR.
now that you've done it correctly, updating the ygot struct, the issue surfaced and the unittests started failing.
I've now adjusted the doublekey schema slightly and updated the related tests as well as the ygot struct.
So from my perspective this PR is good to go!

@henderiw henderiw moved this to Backlog in SDC project Feb 9, 2026
@henderiw henderiw moved this from Backlog to In review in SDC project Feb 9, 2026
Copy link
Contributor

@alexandernorth alexandernorth left a comment

Choose a reason for hiding this comment

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

lgtm

@steiler steiler merged commit 4270e2b into sdcio:main Feb 10, 2026
6 checks passed
@github-project-automation github-project-automation bot moved this from In review to Done in SDC project Feb 10, 2026
@steiler
Copy link
Collaborator

steiler commented Feb 10, 2026

Thanks @markafarrell

@codecov
Copy link

codecov bot commented Feb 10, 2026

Codecov Report

❌ Patch coverage is 72.72727% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pkg/tree/sharedEntryAttributes.go 72.72% 2 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants