Skip to content

docs/api: fix system details schema - #17696

Open
raimundo-henriques wants to merge 2 commits into
canonical:masterfrom
raimundo-henriques:docs/openapi-system-details
Open

raimundo-henriques wants to merge 2 commits into
canonical:masterfrom
raimundo-henriques:docs/openapi-system-details

Conversation

@raimundo-henriques

@raimundo-henriques raimundo-henriques commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Problem

As mentioned in a Copilot comment to PR #17673 , there were three problems with system details:

  1. Field encryption-type of storage-encryption was wrongly named type;
  2. Field availability-check-errors was described as an array of strings and not an array of objects with the error details.
  3. Field volumes was an array of objects with three keys instead of a map of volume names to full gadget volumes; and
  4. Field available-optional was an array of strings and not a map of snap names to a list of components.

Solution

This PR fixes these three problems.
Problem 3. required a rather substantial change. Since gadget volumes are also used on the on-volumes field of action install, a GadgetVolume schema was abstracted and used for both of them.
As a small improvement, this PR also includes an update to the description of unavailable-reason, stating that it must be present if availability-check-errors is non-empty. Enforcing the conditional requirement is unfortunately dependent on updating OpenAPI to v3.1.
The removal of single quotation marks around status codes improves consistency and overlaps with #17673 .

SNAPDENG-36197

Copilot AI left a comment

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.

Copilot review overview

🟡 Changes recommended

The documented unavailable-reason requirement is not guaranteed by the daemon implementation.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Aligns system details OpenAPI schemas with snapd’s wire types.

Changes:

  • Corrects encryption and optional-component schemas.
  • Adds reusable gadget-volume definitions.
  • Updates install volume maps and response formatting.
File Description
SystemDetails.yaml Corrects system details fields.
GadgetVolume.yaml Defines gadget volume structures.
SystemActionInstall.yaml Uses gadget-volume maps.
systems-label.yaml Standardizes response definitions.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +87 to +91
The reason why storage encryption is unavailable or defective. When
a single availability check error is detected, unavailable-reason reports
the error message; when multiple errors are detected, it reports the number of
errors (e.g. 'availability check identified 2 errors'). Must be populated if
availability-check-errors is non-empty.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@ZeyadYasser Is this surfacing an issue with the API or is it indeed the spec that is currently too stringent? Thanks

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.

@valentindavid I don't think this is an issue since the unavailable-reason is mostly for human consumption, wdyt?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

My understanding was that UnavailableErr is about unexpected error while checking the system. And AvailabilityCheckErrors is the error it found on the system. That is if it succeeded to find errors on the system, it will have UnavailableErr being nil, but AvailabilityCheckErrors will have the system issues. If UnavailableErr is set, it means the pre install checks failed to check the system, so the system might be OK, but something else happened.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks @valentindavid . If I get this right, then, the description should probably be more specific. Would the following perhaps suffice?

Suggested change
The reason why storage encryption is unavailable or defective. When
a single availability check error is detected, unavailable-reason reports
the error message; when multiple errors are detected, it reports the number of
errors (e.g. 'availability check identified 2 errors'). Must be populated if
availability-check-errors is non-empty.
The reason why storage encryption is unavailable or defective. When
a single availability check error is detected, unavailable-reason reports
the error message; when multiple errors are detected, it reports the number of
errors (e.g. 'availability check identified 2 errors'). During pre-install, it
must be populated if availability-check-errors is non-empty.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

That sounds like the same... availability-check-errors can be empty the errors are not from the hardware, but from snapd.

We should get confirmation from @ernestl that is the correct thing. Because he worked on it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I thought this could only happen post-install and hence that it mapped onto the pre-install post-install distinction. Thanks!

@ernestl ernestl Sep 24, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The spec description of the intended behavior is correct:

If this list is non-empty, encryption is considered unavailable, and the “unavailable-reason” field must be populated. In the case of a single error, “unavailable-reason” should match the error message, and for multiple errors it should provide an umbrella error message.

This is also why, regardless of the model grade / storage-safety - which results in warning or error in the install.EncryptionSupportInfo, both error and warnings are translated into client.StorageEncryption.UnavailableReason.

However, note that even if there are no secboot availability check error, that does not guarantee empty client.StorageEncryption.UnavailableReason - there may e.g. still be issue with the gadget.


Copilot is correct in pointing out that in the [later post-install check] path (https://github.com/canonical/snapd/blame/master/overlord/devicestate/devicemgr.go#L2901-L2911
) is indeed inconsistent. @valentindavid, I suppose we have to discuss?

I see it is used by used by GET /v2/systems?running=true and by fix-encryption-support when no system label is given.

But the pre-install implementation do follow the spec.

@codecov

codecov Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.39%. Comparing base (7f54f8b) to head (fe0e8fe).
⚠️ Report is 6 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff            @@
##           master   #17696    +/-   ##
========================================
  Coverage   78.38%   78.39%            
========================================
  Files        1418     1417     -1     
  Lines      200785   200586   -199     
  Branches     2503     2503            
========================================
- Hits       157385   157240   -145     
+ Misses      33968    33927    -41     
+ Partials     9432     9419    -13     
Flag Coverage Δ
unittests 78.39% <ø> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

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

@github-actions

github-actions Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

Thu Sep 24 17:29:24 UTC 2026

Spread tests skipped

@raimundo-henriques
raimundo-henriques force-pushed the docs/openapi-system-details branch from 92bc7cc to 0474e33 Compare September 23, 2026 08:12
Fix avaialability-check-errors, previously described as an array of strings.
The new description follows the type used by the API and refers to the secboot library.

Fix the storage-encryption schema on the system details:
- the field describing the encryption type was wrongly named 'type' and was now updated to the correct 'encryption-type';
- the conditional requirement of unavailable-reason (required when availability-check-errors is non-empty) was not documented before.

The volumes field of the system details was wrongly described as an array of objects with three keys.
In reality, it is a map of gadget volumes keyed by volume name.
Since it is also used in the on-volumes field of the install action, a GadgetVolume schema was abstracted and used for both.
It describes the full gadget volume mapping the API.

The available-optional field of system details was also fixed.
It was wrongly described as an array of strings and is now a map of snap names to lists of available component names.
availability-check-errors is non-empty.
availability-check-errors:
type: array
description: A list of errors detected during the preinstall check, as determined by the secboot library.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Striving for consistency regarding the hyphenation of 'pre-install'.

Suggested change
description: A list of errors detected during the preinstall check, as determined by the secboot library.
description: A list of errors detected during the pre-install check, as determined by the secboot library.

@Rnfudge02 Rnfudge02 left a comment

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.

A few questions about the GadgetVolume struct, otherwise its looking go to me!

description: >-
A map of the volumes to operate on, keyed by volume name.
additionalProperties:
$ref: 'GadgetVolume.yaml'

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.

When dealing with the API, do we pass the whole GadgetVolume struct in the request? Or do we just pass the key to the GadgetVolume we are looking to interact with?

Also, do we only pass in one GadgetVolume at a time? If we can pass more than one this should probably still be an array where the items are of type object?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

If I understand correctly, we pass the whole GadgetVolume and more than one, though not as an array. It's a map, keyed by strings (e.g., "pc"):

OnVolumes map[string]*gadget.Volume

(From here)

Mention that order by which the actions to fix pre-install errors
is relevant. This is important to tie together SystemDetails and
the fix-encryption-support action.

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

Labels

Documentation Skip spread Indicate that spread job should not run

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants