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

Add OpenAPI #10186

Merged
merged 31 commits into from
Oct 6, 2023
Merged

Add OpenAPI #10186

merged 31 commits into from
Oct 6, 2023

Conversation

provokateurin
Copy link
Member

☑️ Resolves

Adds all the utilities and annotations required for OpenAPI.

🏁 Checklist

openapi.json Outdated Show resolved Hide resolved
@provokateurin
Copy link
Member Author

I remember seeing a psalm failure with not enough memory at some point, I believe it's a memory leak that nukes psalm. Just giving it more ram didn't fix it, although I don't have this problem locally 🤔

Copy link
Member

@nickvergessen nickvergessen left a comment

Choose a reason for hiding this comment

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

Psalm breakage is not acceptable.
Also locally it does no longer finish and runs out of memory after allocating 8GB !

@nickvergessen nickvergessen added feature: api 🛠️ OCS API for conversations, chats and participants technical debt labels Aug 14, 2023
@provokateurin
Copy link
Member Author

Rebased on master to resolve conflicts and check if newer psalm version fixes the memory crash. Psalm still works perfectly on my machine 🤷‍♀️

@provokateurin
Copy link
Member Author

provokateurin commented Sep 4, 2023

Ok here are my investigation results:

  1. Reproducing sucessfully on clean ubuntu:jammy and debian:bookworm docker images -> No ubuntu specific problem
  2. Installed PHP 8.2 on ubuntu:jammy -> No PHP 8.1 specific problem
  3. Reproducing successfully on a clean archlinux:latest docker image -> No non-ArchLinux specific problem
  4. Copied my php.ini into the archlinux:latest docker image and the problem is still reproducible.

I will update this comment when I have new findings.

@nickvergessen
Copy link
Member

I found out, that even with old dependencies the problem existed.

So I rebased this PR and turned around the stuff:

  1. set up CI, dependency, etc.
  2. then the doc modifications

Turns out, after 1 psalm still worked, but not after 2

So I started a git bisect:

$ git bisect log
git bisect start
# status: waiting for both good and bad commits
# good: [152a2cd9e04015eb0273ba77e128ea3ca69df1a3] Add OpenAPI CI
git bisect good 152a2cd9e04015eb0273ba77e128ea3ca69df1a3
# good: [152a2cd9e04015eb0273ba77e128ea3ca69df1a3] Add OpenAPI CI
git bisect good 152a2cd9e04015eb0273ba77e128ea3ca69df1a3
# bad: [8bb03633903b7b9d0b0550545858d2e06f38e6ae] Add annotations for PollController
git bisect bad 8bb03633903b7b9d0b0550545858d2e06f38e6ae
# good: [a7527f2ca7a812bece1944d4b573ebcafd56de29] Add annotations for ChatController
git bisect good a7527f2ca7a812bece1944d4b573ebcafd56de29
# good: [4cfc169c02f47418d79763e2da2c48dbed9da628] Add annotations for GuestController
git bisect good 4cfc169c02f47418d79763e2da2c48dbed9da628
# bad: [81588e0c022112ab054bb55cd420a47b199c0132] Add annotations for MatterbridgeController
git bisect bad 81588e0c022112ab054bb55cd420a47b199c0132
# good: [5c8a9f3b46980ee02ca3b13b0bbff11b01bc0b56] Add annotations for HostedSignalingServerController
git bisect good 5c8a9f3b46980ee02ca3b13b0bbff11b01bc0b56
# first bad commit: [81588e0c022112ab054bb55cd420a47b199c0132] Add annotations for MatterbridgeController

So I had a look at that commit and found the problem:
https://github.com/nextcloud/spreed/pull/10186/files#diff-4489f22fe309430bc8a3e0cc90a0410de61dd9b7b231d5b6f8680310f3b75ad5R59

	 * @return DataResponse<Http::STATUS_OK, SpreedMatterbridge&SpreedMatterbridgeProcessState, array{}>

from getBridgeOfRoom fixes the memory issue.

After some testing the following patch also fixes it:

diff --git a/lib/Controller/MatterbridgeController.php b/lib/Controller/MatterbridgeController.php
index 65e15eb1f..aac46265a 100644
--- a/lib/Controller/MatterbridgeController.php
+++ b/lib/Controller/MatterbridgeController.php
@@ -40,6 +40,7 @@ use OCP\IRequest;
  * @psalm-import-type SpreedMatterbridge from ResponseDefinitions
  * @psalm-import-type SpreedMatterbridgeParts from ResponseDefinitions
  * @psalm-import-type SpreedMatterbridgeProcessState from ResponseDefinitions
+ * @psalm-import-type SpreedMatterbridgeWithProcessState from ResponseDefinitions
  */
 class MatterbridgeController extends AEnvironmentAwareController {
 
@@ -56,7 +57,7 @@ class MatterbridgeController extends AEnvironmentAwareController {
        /**
         * Get bridge information of one room
         *
-        * @return DataResponse<Http::STATUS_OK, SpreedMatterbridge&SpreedMatterbridgeProcessState, array{}>
+        * @return DataResponse<Http::STATUS_OK, SpreedMatterbridgeWithProcessState, array{}>
         */
        #[NoAdminRequired]
        #[RequireLoggedInModeratorParticipant]
diff --git a/lib/ResponseDefinitions.php b/lib/ResponseDefinitions.php
index 49b82c41a..664aa7284 100644
--- a/lib/ResponseDefinitions.php
+++ b/lib/ResponseDefinitions.php
@@ -209,6 +209,8 @@ namespace OCA\Talk;
  *     running: bool,
  * }
  *
+ * @psalm-type SpreedMatterbridgeWithProcessState = SpreedMatterbridge&SpreedMatterbridgeProcessState
+ *
  * @psalm-type SpreedSignalingSettings = array{
  *     helloAuthParams: array{
  *         "1.0": array{

@nickvergessen
Copy link
Member

So now that we are able to solve the problem, I will take over and migrate the responses to the expected namespace and see where we can simply the things.

@provokateurin
Copy link
Member Author

Thanks for the debugging. The openapi-extractor still doesn't support reading the namespace as per nextcloud/openapi-extractor#11

@provokateurin
Copy link
Member Author

Since this PR there have been a few fixes in openapi-extractor, so please upgrade it to the latest version before continuing.
It would be nice if I could reviewyour changes as well, since this whole thing is quite complex.

@nickvergessen
Copy link
Member

The openapi-extractor still doesn't support reading the namespace as per nextcloud/openapi-extractor#11

Neither the version it seems (locking 0.0.1 while talk is at 18.0…). Will try to have a look

@provokateurin
Copy link
Member Author

The version field does not indicate the version of the software but the version of the document instead. This is a common misconception, but the right way to do it (until I've found a better solution)

@nickvergessen
Copy link
Member

The version field does not indicate the version of the software but the version of the document instead.

Okay, so it updates automatically everytime something changes? Or is hardcoded? Because it should reflect to breaking changes (api removed), etc I guess?

Signed-off-by: jld3103 <jld3103yt@gmail.com>
Signed-off-by: jld3103 <jld3103yt@gmail.com>
Signed-off-by: jld3103 <jld3103yt@gmail.com>
Signed-off-by: jld3103 <jld3103yt@gmail.com>
Signed-off-by: jld3103 <jld3103yt@gmail.com>
Signed-off-by: jld3103 <jld3103yt@gmail.com>
Signed-off-by: jld3103 <jld3103yt@gmail.com>
Signed-off-by: jld3103 <jld3103yt@gmail.com>
Signed-off-by: jld3103 <jld3103yt@gmail.com>
provokateurin and others added 15 commits October 6, 2023 12:41
Signed-off-by: jld3103 <jld3103yt@gmail.com>
Signed-off-by: jld3103 <jld3103yt@gmail.com>
Signed-off-by: jld3103 <jld3103yt@gmail.com>
Signed-off-by: jld3103 <jld3103yt@gmail.com>
Signed-off-by: jld3103 <jld3103yt@gmail.com>
Signed-off-by: jld3103 <jld3103yt@gmail.com>
Signed-off-by: jld3103 <jld3103yt@gmail.com>
Signed-off-by: jld3103 <jld3103yt@gmail.com>
Signed-off-by: jld3103 <jld3103yt@gmail.com>
Signed-off-by: jld3103 <jld3103yt@gmail.com>
Signed-off-by: jld3103 <jld3103yt@gmail.com>
Signed-off-by: Joas Schilling <coding@schilljs.com>
Signed-off-by: Joas Schilling <coding@schilljs.com>
Signed-off-by: Joas Schilling <coding@schilljs.com>
Signed-off-by: Joas Schilling <coding@schilljs.com>
@nickvergessen
Copy link
Member

After aligning with Kate in the chat, I squashed the fixups, kept my changes in individual commits for easier retrospective and rebased it.
So we can merge it and rebase all open PHP PRs

@nickvergessen nickvergessen merged commit d4b5c75 into master Oct 6, 2023
52 checks passed
@nickvergessen nickvergessen deleted the feature/openapi branch October 6, 2023 11:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2. developing feature: api 🛠️ OCS API for conversations, chats and participants technical debt
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants