Skip to content

Conversation

@jreidinger
Copy link
Contributor

@jreidinger jreidinger commented Jul 16, 2025

Problem

It is possible to not specify product in agama profile and it can lead to crash in ruby code or unexpected results.

bugzilla: https://bugzilla.suse.com/show_bug.cgi?id=1246601

Solution

For parts that needs product to be already selected add check and report error if it is not the case.

Testing

  • Tested manually

Screenshots

output before:

agama2:~ # agama config load < profile.jsonnet 
✓ The profile is valid.

Error processing storage settings: Backend call failed with status 400 and text '{"error":"Agama service error: D-Bus service error: org.freedesktop.DBus.Error.Failed: undefined method 'reject' for nil; caused by 1 sender=:1.1 -> dest=org.opensuse.Agama.Storage1 serial=219 reply_serial= path=/org/opensuse/Agama/Storage1; interface=org.opensuse.Agama.Storage1; member=Reprobe error_name="}'

Caused by:
    Backend call failed with status 400 and text '{"error":"Agama service error: D-Bus service error: org.freedesktop.DBus.Error.Failed: undefined method 'reject' for nil; caused by 1 sender=:1.1 -> dest=org.opensuse.Agama.Storage1 serial=219 reply_serial= path=/org/opensuse/Agama/Storage1; interface=org.opensuse.Agama.Storage1; member=Reprobe error_name="}'

and output with fix:

agama2:~ # agama config load < profile.jsonnet 
✓ The profile is valid.

Cannot proceed with profile without specified product

@coveralls
Copy link

Coverage Status

coverage: 64.101% (+0.06%) from 64.04%
when pulling 4758096 on product_fix
into e8f1c2c on master.

@coveralls
Copy link

coveralls commented Jul 16, 2025

Coverage Status

coverage: 76.037% (+11.7%) from 64.317%
when pulling 96d0b1c on product_fix
into 5249cbc on master.

@jreidinger jreidinger marked this pull request as ready for review July 16, 2025 19:06
Ok(!product.is_empty())
}

fn check_selected_product(selected: bool) -> Result<(), StoreError> {
Copy link
Contributor

Choose a reason for hiding this comment

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

I would prefer ensure_selected_product because it communicates better the intention.

#[error("Could not calculate the context")]
InvalidStoreContext,
#[error("Cannot proceed with profile without specified product")]
ProductMissing,
Copy link
Contributor

Choose a reason for hiding this comment

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

np: MissingProduct (as InvalidStoreContext, MissingDevice, etc.).

@jreidinger jreidinger merged commit 3b63aa9 into master Jul 17, 2025
18 checks passed
@jreidinger jreidinger deleted the product_fix branch July 17, 2025 11:56
@imobachgs imobachgs mentioned this pull request Jul 21, 2025
imobachgs added a commit that referenced this pull request Jul 21, 2025
imobachgs added a commit that referenced this pull request Jul 29, 2025
…2623)

## Problem

#2570 introduced a check to make sure that a product is selected in some
cases when the user tries to load a configuration that contains some
specific sections (basically software and storage-related ones).

However, `agama config load` now complains *always*.

## Solution

The root cause is that, when deserializing the settings, a users section
is *always* present (due to the use of `flatten` and optional fields).
However, the users section does not require the product anymore.

## Testing

- Tested manually
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.

4 participants