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

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

Open
oSoMoN opened this issue Oct 15, 2024 · 1 comment

Comments

@oSoMoN
Copy link
Collaborator

oSoMoN commented Oct 15, 2024

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
Copy link
Collaborator

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?

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

No branches or pull requests

2 participants