Bug 58250 - Logic error in group.py
Summary: Logic error in group.py
Status: CLOSED FIXED
Alias: None
Product: UCS@school
Classification: Unclassified
Component: Ucsschool-lib
Version: UCS@school 5.2
Hardware: Other Linux
: P5 normal
Target Milestone: UCS@school 5.2 v2-errata
Assignee: Sönke Schwardt-Krummrich
QA Contact: Jürn Brodersen
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-05-06 18:07 CEST by Sönke Schwardt-Krummrich
Modified: 2025-05-27 11:22 CEST (History)
1 user (show)

See Also:
What kind of report is it?: Development Internal
What type of bug is this?: ---
Who will be affected by this bug?: ---
How will those affected feel about the bug?: ---
User Pain:
Enterprise Customer affected?:
School Customer affected?:
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number:
Bug group (optional):
Customer ID:
Max CVSS v3 score:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sönke Schwardt-Krummrich univentionstaff 2025-05-06 18:07:26 CEST
Logic error in UCS@school lib:

ucs-school-lib/modules/ucsschool/lib/models/group.py:

---[cut]---
class _MayHaveSchoolSuffix(object):
    def get_relative_name(self):  # type: () -> str
        # schoolname-1a => 1a
        if (
            self.school
            and self.name.lower().endswith("-%s" % self.school.lower())
            or self.name.lower().endswith(" %s" % self.school.lower())
        ):
            return self.name[: -(len(self.school) + 1)]
        return self.name
---[cut]---

If self.school is None, the code will throw a traceback because "and" has higher priority than "or". Currently the code semantically looks like this:

        if (
            (self.school and self.name.lower().endswith("-%s" % self.school.lower()))
            or self.name.lower().endswith(" %s" % self.school.lower())
        ):

but it should be

        if self.school and (
            self.name.lower().endswith("-%s" % self.school.lower())
            or self.name.lower().endswith(" %s" % self.school.lower())
        ):
Comment 1 Sönke Schwardt-Krummrich univentionstaff 2025-05-06 18:45:29 CEST
- Fixed with ucs-school-lib 15.0.3
- Unittest has been added
Comment 2 Jürn Brodersen univentionstaff 2025-05-07 10:27:32 CEST
Jenkins looks good -> OK
changelog -> OK
build -> OK
Comment 3 Johannes Königer univentionstaff 2025-05-27 11:22:02 CEST
Errata updates for UCS@school 5.2 v2 have been released.

https://docs.software-univention.de/ucsschool-changelog/5.2v2/en/changelog.html
https://docs.software-univention.de/ucsschool-changelog/5.2v2/de/changelog.html

If this error occurs again, please clone this bug.