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

Warning on NetworkSettings normalizer #3

Open
rodrigoaguilera opened this issue Sep 12, 2021 · 6 comments
Open

Warning on NetworkSettings normalizer #3

rodrigoaguilera opened this issue Sep 12, 2021 · 6 comments

Comments

@rodrigoaguilera
Copy link
Collaborator

I am getting

<warning>PHP Warning:  foreach() argument must be of type array|object, null given in /vendor/beluga-php/docker-php-api/src/Normalizer/NetworkSettingsNormalizer.php on line 73</warning>

Calling containerInspect() for a container that has ports exposed on the image but no binding so the output of CLI docker inspect is

...
"NetworkSettings": {
            "Bridge": "",
            "SandboxID": "2b1a12bda80af0896525136538f1495c0097ae592134a387fa0ea3173804c1d3",
            "HairpinMode": false,
            "LinkLocalIPv6Address": "",
            "LinkLocalIPv6PrefixLen": 0,
            "Ports": {
                "9000/tcp": null
            },
...

I guess the daemon used to return an array for the port bindings instead of null.
I am using Docker Server Version: 20.10.5.

@rodrigoaguilera
Copy link
Collaborator Author

I think the code generated doesn't take into account that the items inside a PortMap are nullable
https://github.com/beluga-php/docker-php-api/blob/main/spec/v1.41.json#L11916

@flavioheleno
Copy link
Member

Hi @rodrigoaguilera, could you kindly provide a simple script to reproduce the issue?

@rodrigoaguilera
Copy link
Collaborator Author

Sure.
Run this in directory where you have the php docker client installed with composer:

docker run --rm --detach --name=test wodby/drupal-php:8.0-4.27.3
php -r "include 'vendor/autoload.php'; \Docker\Docker::create()->containerInspect('test');"

That drupal-php image exposes the port 9000

@flavioheleno
Copy link
Member

Got to reproduce the issue here. You are right, the generator does not properly handle PortMap being nullable (likely to happen somewhere else too).

I've fiddled with the configuration options and even bumping JanePHP to 7.x, but without any success.

The fix is rather simple if we do it in the generated code, but that would be non-practical moving forward without a "patching" process in place to keep track of those changes.

I'll do some more digging and figure out why the generated code isn't right and maybe propose a fix to JanePHP if that's the case.

@Rid
Copy link
Member

Rid commented Oct 8, 2021

I have reported this here: janephp/janephp#559

@flavioheleno
Copy link
Member

Sorry for the very late response to this, but I'm trying to fix is in JanePHP (janephp/janephp#597) :)

PS: Dealing with Jane code base is not at all easy. phew!

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

3 participants