SUSE / osc-tiny

Documentation
https://osc-tiny.readthedocs.io/
MIT License
12 stars 10 forks source link

osctiny.models.request.Review model is missing a mandatory 'state' attribute #194

Open oSoMoN opened 4 days ago

oSoMoN commented 4 days ago

The schema definition for the <review> node in a request requires a mandatory state attribute, but the corresponding model in osctiny doesn't have that attribute.

crazyscientist commented 3 days ago

Seriously? The client has to specify a state attribute just so that the server can ignore it?

Example

Request submission

Assuming I extend the Review model to submit a specified state:

from lxml.etree import tounicode
from osctiny import Osc
from osctiny.models.request import Action, ActionType, By, Source, Target, Review
from requests.exceptions import HTTPError

o = Osc("https://api.opensuse.org", "apritschet", "******")
action = Action(type=ActionType.SUBMIT,
                source=Source(project="home:apritschet", package="plantuml"),
                target=Target(project="home:apritschet", package="plantuml.bak"))
review = Review(by=By.USER, name="apritschet", state="declined")
print("REVIEW", tounicode(review.asxml()))

try:
    request_id = o.requests.create(
        actions=[action],
        reviewers=[review],
        description="Test review model"
    )
except HTTPError as error:
    print("ERROR", error.response.content)
else:
    print("Request ID:", request_id)

results in

REVIEW <review by_user="apritschet" state="declined"/>
Request ID: 1208298

Request on OBS

osc -A https://api.opensuse.org api /request/1208298
<request id="1208298" creator="apritschet">
  <action type="submit">
    <source project="home:apritschet" package="plantuml" rev="e4f2f428e501bddc4c1a639638117dbb"/>
    <target project="home:apritschet" package="plantuml.bak"/>
  </action>
  <state name="review" who="apritschet" when="2024-10-16T07:41:06" created="2024-10-16T07:41:06">
    <comment/>
  </state>
  <review state="new" when="2024-10-16T07:41:06" by_user="apritschet"/>
  <description>Test review model</description>
</request>

Conclusion

So, I requested to create a request with a review in a specific state, but OBS ignores the value; it only insists on the presence of the attribute.

IMHO, the behavior of the OBS API is wrong. Would you like to report an issue for OBS?