owncloud / ocis

:atom_symbol: ownCloud Infinite Scale Stack
https://doc.owncloud.com/ocis/next/
Apache License 2.0
1.36k stars 180 forks source link

WOPI / app provider panics if /hosting/discovery endpoint returns 404 #4882

Closed wkloucek closed 1 year ago

wkloucek commented 1 year ago

Describe the bug

If the /hosting/discovery endpoint of a WOPI app returns a 404 (eg. if WOPI is not enabled for OnlyOffice), the app provider panics.

Expected behavior

Print a clear and concise error message, eg:

WOPI discovery failed. The endpoint returned status code 404. Do you have WOPI enabled on your office server?

Actual behavior

Stacktrace:

owncloud/ocis:2.0.0-beta.8 app-provider server
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x40 pc=0x119c1cd]

goroutine 67 [running]:
github.com/beevik/etree.(*Element).SelectElements(0x0, {0x2094e1f?, 0xc0003868c0?})
    github.com/beevik/etree@v1.1.0/etree.go:759 +0x4d
github.com/cs3org/reva/v2/pkg/app/provider/wopi.parseWopiDiscovery({0x7fd8db50f198, 0xc0003868c0})
    github.com/cs3org/reva/v2@v2.10.0/pkg/app/provider/wopi/wopi.go:391 +0x10f
github.com/cs3org/reva/v2/pkg/app/provider/wopi.getAppURLs(0xc000e4c6c0)
    github.com/cs3org/reva/v2@v2.10.0/pkg/app/provider/wopi/wopi.go:324 +0x86b
github.com/cs3org/reva/v2/pkg/app/provider/wopi.New(0x3892260?)
    github.com/cs3org/reva/v2@v2.10.0/pkg/app/provider/wopi/wopi.go:102 +0xd0
github.com/cs3org/reva/v2/internal/grpc/services/appprovider.getProvider(0xc0008a5920)
    github.com/cs3org/reva/v2@v2.10.0/internal/grpc/services/appprovider/appprovider.go:167 +0x6c
github.com/cs3org/reva/v2/internal/grpc/services/appprovider.New(0x3892260?, 0xc00004f440?)
    github.com/cs3org/reva/v2@v2.10.0/internal/grpc/services/appprovider/appprovider.go:87 +0x33
github.com/cs3org/reva/v2/pkg/rgrpc.(*Server).registerServices(0xc0009d30e0)
    github.com/cs3org/reva/v2@v2.10.0/pkg/rgrpc/rgrpc.go:180 +0x1ee
github.com/cs3org/reva/v2/pkg/rgrpc.(*Server).Start(0xc0009d30e0, {0x3caed68?, 0xc000e33ad0})
    github.com/cs3org/reva/v2@v2.10.0/pkg/rgrpc/rgrpc.go:143 +0x3a
github.com/cs3org/reva/v2/cmd/revad/runtime.start.func2()
    github.com/cs3org/reva/v2@v2.10.0/cmd/revad/runtime/runtime.go:200 +0x9c
created by github.com/cs3org/reva/v2/cmd/revad/runtime.start
    github.com/cs3org/reva/v2@v2.10.0/cmd/revad/runtime/runtime.go:199 +0x27f
wkloucek commented 1 year ago

This happens if the office applications returns HTTP status 200 but does not return xml, for example in our case:

image

kobergj commented 1 year ago

fix here: https://github.com/cs3org/reva/pull/3394

kobergj commented 1 year ago

Fixed in current master