fusio icon indicating copy to clipboard operation
fusio copied to clipboard

problem with route /aroute/$var<[0-9]+> matches /aroute/123 but also /aroute/123A

Open mmaateurol opened this issue 4 years ago • 5 comments

Checking this it just uses te uri parameter as input for the sqlallrows

mmaateurol avatar Dec 08 '21 09:12 mmaateurol

Hi, could you try to use /aroute/$var<^[0-9]+$> as route, this basically means that the start and end of the value must only contain 9-0 characters.

chriskapp avatar Dec 09 '21 18:12 chriskapp

as soon as i set begin and and end

<^[0-9]+$>  ( lots of digits )
<\A[0-9]{1,2}\z>   ( 1 or 2 digits )

and try \aroute\1a \aroute\1234 ( to check the 2nd ) I get an InvalidPathException as expected

But with \aroute\1 i dont dont get the InvalidPathException. But the rest of the handling goes wrong : And get the following error:

{
    "success": false,
    "title": "PSX\\Http\\Exception\\InternalServerErrorException",
    "message": "No specification available in D:\\Sites\\fusio\\vendor\\psx\\framework\\src\\Controller\\SchemaApiAbstract.php on line 83",
    "trace": "#0 D:\\Sites\\fusio\\vendor\\psx\\framework\\src\\Controller\\ControllerAbstract.php(144): PSX\\Framework\\Controller\\SchemaApiAbstract->onLoad()
#1 D:\\Sites\\fusio\\vendor\\psx\\http\\src\\Filter\\FilterChain.php(110): PSX\\Framework\\Controller\\ControllerAbstract->handle()
#2 D:\\Sites\\fusio\\vendor\\fusio\\impl\\src\\Controller\\Filter\\Logger.php(68): PSX\\Http\\Filter\\FilterChain->handle()
#3 D:\\Sites\\fusio\\vendor\\psx\\http\\src\\Filter\\FilterChain.php(110): Fusio\\Impl\\Controller\\Filter\\Logger->handle()
#4 D:\\Sites\\fusio\\vendor\\fusio\\impl\\src\\Controller\\Filter\\RequestLimit.php(74): PSX\\Http\\Filter\\FilterChain->handle()
#5 D:\\Sites\\fusio\\vendor\\psx\\http\\src\\Filter\\FilterChain.php(110): Fusio\\Impl\\Controller\\Filter\\RequestLimit->handle()
#6 D:\\Sites\\fusio\\vendor\\fusio\\impl\\src\\Controller\\Filter\\Authentication.php(66): PSX\\Http\\Filter\\FilterChain->handle()
#7 D:\\Sites\\fusio\\vendor\\psx\\http\\src\\Filter\\FilterChain.php(110): Fusio\\Impl\\Controller\\Filter\\Authentication->handle()
#8 D:\\Sites\\fusio\\vendor\\fusio\\impl\\src\\Controller\\Filter\\AssertMethod.php(99): PSX\\Http\\Filter\\FilterChain->handle()
#9 D:\\Sites\\fusio\\vendor\\psx\\http\\src\\Filter\\FilterChain.php(110): Fusio\\Impl\\Controller\\Filter\\AssertMethod->handle()
#10 D:\\Sites\\fusio\\vendor\\psx\\http\\src\\Filter\\UserAgentEnforcer.php(43): PSX\\Http\\Filter\\FilterChain->handle()
#11 D:\\Sites\\fusio\\vendor\\psx\\http\\src\\Filter\\FilterChain.php(110): PSX\\Http\\Filter\\UserAgentEnforcer->handle()
#12 D:\\Sites\\fusio\\vendor\\psx\\http\\src\\Filter\\CORS.php(107): PSX\\Http\\Filter\\FilterChain->handle()
#13 D:\\Sites\\fusio\\vendor\\psx\\http\\src\\Filter\\FilterChain.php(110): PSX\\Http\\Filter\\CORS->handle()
#14 D:\\Sites\\fusio\\vendor\\psx\\framework\\src\\Loader\\Loader.php(123): PSX\\Http\\Filter\\FilterChain->handle()
#15 D:\\Sites\\fusio\\vendor\\psx\\framework\\src\\Loader\\Loader.php(102): PSX\\Framework\\Loader\\Loader->execute()
#16 D:\\Sites\\fusio\\vendor\\psx\\framework\\src\\Dispatch\\Dispatch.php(126): PSX\\Framework\\Loader\\Loader->load()
#17 D:\\Sites\\fusio\\vendor\\psx\\engine\\src\\WebServer\\Engine.php(58): PSX\\Framework\\Dispatch\\Dispatch->route()
#18 D:\\Sites\\fusio\\vendor\\psx\\framework\\src\\Environment\\Environment.php(70): PSX\\Engine\\WebServer\\Engine->serve()
#19 D:\\Sites\\fusio\\public\\index.php(28): PSX\\Framework\\Environment\\Environment->serve()
#20 {main}",
    "context": "79  
80          \/\/ get the current specification based on the context
81          $specification = $this-&gt;resourceListing-&gt;find($this-&gt;context-&gt;getPath(), $this-&gt;context-&gt;getVersion());
82          if (!$specification instanceof SpecificationInterface) {
<b>83              throw new StatusCode\\InternalServerErrorException('No specification available');
<\/b>84          }
85  
86          $resource = $specification-&gt;getResourceCollection()-&gt;get($this-&gt;context-&gt;getPath());
87          if (!$resource instanceof Resource) {
"
}

mmaateurol avatar Dec 10 '21 07:12 mmaateurol

@chriskapp is this not a 'bug' instead of a 'question' ?

mmaateurol avatar Dec 17 '21 08:12 mmaateurol

Maybe to set the scheme for URI Paramater

Open API

  parameters:
    - name: id
      in: path
      required: true
      schema:
        type: integer   

mmaateurol avatar Dec 17 '21 08:12 mmaateurol

Hey @mmaateurol yes you are right this is indeed a bug, probably we should automatically add the ^[regex]$ around the regex, which should then solve the problem. but we need to check whats the best way to fix this. Regarding the type for the spec, currently an variable uri fragment is always a string since it is difficult to detect the correct type based on the used regex but maybe there is a solution for such a problem.

chriskapp avatar Dec 17 '21 17:12 chriskapp