Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid warning about use of uninitialized value #5540

Closed
wants to merge 1 commit into from

Conversation

Martchus
Copy link
Contributor

The variable $testsuite_name might be undef if the spec is an empty hash leading to:

Use of uninitialized value $testsuite_name in hash element at /usr/share/openqa/script/../lib/OpenQA/Schema/Result/JobGroups.pm line 413.

We can just skip empty specs here avoiding the warning.

The variable `$testsuite_name` might be `undef` if the spec is an empty
hash leading to:

```
Use of uninitialized value $testsuite_name in hash element at /usr/share/openqa/script/../lib/OpenQA/Schema/Result/JobGroups.pm line 413.
```

We can just skip empty specs here avoiding the warning.
Copy link

codecov bot commented Mar 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.39%. Comparing base (e985d28) to head (3a4a737).
Report is 96 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #5540   +/-   ##
=======================================
  Coverage   98.39%   98.39%           
=======================================
  Files         391      391           
  Lines       38039    38039           
=======================================
  Hits        37427    37427           
  Misses        612      612           

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

@perlpunk
Copy link
Contributor

where did you see this error? do you have the according yaml file?

@Martchus
Copy link
Contributor Author

In the log on OSD and no, I don't have the yaml file.

@@ -409,7 +409,7 @@ sub _parse_job_template_products ($yaml_products_for_arch, $yaml_defaults_for_ar
my $description = '';
if (ref $spec eq 'HASH') {
# We only have one key. Asserted by schema
$testsuite_name = (keys %$spec)[0];
next unless $testsuite_name = (keys %$spec)[0];
Copy link
Member

Choose a reason for hiding this comment

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

What does this case look like? As the comment even says, this should have been validated beforehand.

Copy link
Contributor

Choose a reason for hiding this comment

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

I had a look in the log:
journal:

Mar 21 14:49:58 openqa openqa[29349]: Use of uninitialized value $testsuite_name in hash element at /usr/share/openqa/script/../lib/OpenQA/Schema/Result/JobGroups.pm line 413.

accesslog:

[21/Mar/2024:14:49:58 +0100] "POST /api/v1/job_templates_scheduling/510
[21/Mar/2024:14:49:58 +0100] "POST /api/v1/job_templates_scheduling/319
[21/Mar/2024:14:49:58 +0100] "POST /api/v1/job_templates_scheduling/456

Looking at
https://openqa.suse.de/admin/job_templates/319, it has:

scenarios:
# ...
  s390x:
    sle-15-SP6-Migration-from-SLE15-SPx-s390x:
      - {}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I suppose an empty hash is considered valid here. It probably might make even sense as a "null value" (and this change would to the right thing then).

Copy link
Contributor

Choose a reason for hiding this comment

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

Currently it would still call _parse_job_template_machines() below with an undefined value.
If this is skipped, then the result might be different.
I just had a look at the job template editor and clicked on "Show expanded version and got this:

scenarios:
# ...
  s390x:
    sle-15-SP6-Migration-from-SLE15-SPx-s390x:
    - '':
        machine: s390x-kvm
        priority: 50
        settings: {}

I think with this PR this entry wouldn't be there anymore.
But also an empty string for the testsuite name doesn't make much sense.
I also looked into the database and we have a lot of entries like this with an empty name:

select id, product_id, test_suite_id, t_updated, group_id, name from job_templates where group_id=319 limit 20;
   id   | product_id | test_suite_id |      t_updated      | group_id |                               name                                
--------+------------+---------------+---------------------+----------+-------------------------------------------------------------------
...
 255410 |       2690 |          5576 | 2023-10-19 06:27:17 |      319 | 

Copy link
Member

Choose a reason for hiding this comment

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

FYI I retroactively filed this as poo#157774

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor

@perlpunk perlpunk left a comment

Choose a reason for hiding this comment

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

See my comments. I'm not completely sure if it might break things

@Martchus
Copy link
Contributor Author

Superseded by #5583.

@Martchus Martchus closed this Apr 22, 2024
@Martchus Martchus deleted the warning branch April 22, 2024 15:49
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.

4 participants