Demonstrator - Reasoning WebAPI issueshttps://gitlab.rz.uni-bamberg.de/cogsys/dare2del/demonstrator/-/issues2020-12-10T18:37:36Zhttps://gitlab.rz.uni-bamberg.de/cogsys/dare2del/demonstrator/-/issues/2Define JSON scheme for API IO & Write Wiki2020-12-10T18:37:36ZSebastian SeufertDefine JSON scheme for API IO & Write WikiSebastian SeufertSebastian Seuferthttps://gitlab.rz.uni-bamberg.de/cogsys/dare2del/demonstrator/-/issues/4Design server responses for "unexplainable" atoms.2020-12-10T18:35:59ZSiebers, MichaelDesign server responses for "unexplainable" atoms.Currently, explain/4 succeeds only if the atom to explain is true and an explanation can be constructed. For the first part this is intended: if the atom is false an "explanation why this is true" does not make sense. However, what is th...Currently, explain/4 succeeds only if the atom to explain is true and an explanation can be constructed. For the first part this is intended: if the atom is false an "explanation why this is true" does not make sense. However, what is the desired server response in that case? It probably should not be a 500, since there is no server-side error as such. Maybe a 200 with no payload?
What about the second part? When no explanation can be constructed for a true atom this is indeed an error. However, this probably should only happen if the domain designer made a mistake (e.g., forgot an explanation template). So this is probably also no 500.
Both errors should be distinguishable by the client.Version 1.0Sebastian SeufertSebastian Seuferthttps://gitlab.rz.uni-bamberg.de/cogsys/dare2del/demonstrator/-/issues/13Bug in same_directory/22020-11-09T12:49:10ZSiebers, MichaelBug in same_directory/2The predicate same_directory/2 relies on in_directory/2. This produces a trailing slash on path names, which hinders matching of the absolute path name of the parent directory.
Why do unit tests for in_directory/1 and same_directory/2 p...The predicate same_directory/2 relies on in_directory/2. This produces a trailing slash on path names, which hinders matching of the absolute path name of the parent directory.
Why do unit tests for in_directory/1 and same_directory/2 pass?Siebers, MichaelSiebers, Michaelhttps://gitlab.rz.uni-bamberg.de/cogsys/dare2del/demonstrator/-/issues/20/explain: Is it supposed to be like this?2020-11-23T15:35:40ZSyed Mamoon Ahmed/explain: Is it supposed to be like this?Please tell me what am I doing wrong?
Here is my request:
> {
> "abs_path": "/A/B/Filename-2.exe"
> }
Here is the response:
> HTTP/1.1 400 Bad Request
> Date: Mon, 16 Nov 2020 21:43:23 GMT
> Connection: close
> Content-Le...Please tell me what am I doing wrong?
Here is my request:
> {
> "abs_path": "/A/B/Filename-2.exe"
> }
Here is the response:
> HTTP/1.1 400 Bad Request
> Date: Mon, 16 Nov 2020 21:43:23 GMT
> Connection: close
> Content-Length: 350
> Content-Type: text/html; charset=UTF-8
>
> <!DOCTYPE html>
> <html>
> <head>
> <title>400 Bad Request</title>
>
> <meta http-equiv="content-type" content="text/html; charset=UTF-8">
>
> </head>
> <body>
>
> <h1>Bad Request</h1>
>
> <p>
> Unknown message: not_irrelevant('/A/B/Filename-2.exe')</p>
>
> <address>
> <a href="http://www.swi-prolog.org">SWI-Prolog</a> httpd at transmatter-laptop
> </address>
>
> </body>
> </html>Sebastian SeufertSebastian Seuferthttps://gitlab.rz.uni-bamberg.de/cogsys/dare2del/demonstrator/-/issues/27Add regex types to types module2020-12-01T01:41:16ZSiebers, MichaelAdd regex types to types module# Current state
In the types module the type of objects can be checked. This is not restricted to Prolog's definition of types: at least for dicts required and optional keys (with type restrictions) may be defined.
# Suggestion
The rege...# Current state
In the types module the type of objects can be checked. This is not restricted to Prolog's definition of types: at least for dicts required and optional keys (with type restrictions) may be defined.
# Suggestion
The regex type would extend this idea to strings: the value must not only be of type string but its content must satisfy additional requirements. Additionally, a regex type for `atom`s or general `text` is desired.
## Rationale
We have decided, that absolute paths of files and directories may not end in a slash unless it is the root directory '/'. Without the regex type, this restriction must be enforced after type checking. However for this, a mechanisms very similar to type checking are required. For example in `set_bg`:
- if we have a single dict:
- noting which values are concerned (probably only `abs_path`),
- extracting the value
- *checking the regex*
- if the check fails: throw exception
- if we have a list of dicts:
- iterate over all elements
- if we then have a dict, apply the steps from above
It is easier, less error prone, and more encapsulated to include this facility into types.
## Technical realisation
The actual checking of the type might be simple as there is a regex library in Prolog. Taking strings as example, the type definition could look like
- `regex(string, RegEx)` where `RegEx` must be a valid regular expression from Prolog's regex library or
- `string(RegEx)` where `RegEx`is defined as above.
The second option would convey the notion that this is a refinement of the string type more strongly. This is analogous to `dict` vs. `dict/1` and `dict/2` and `list` vs `list/1` already realized in `types`.https://gitlab.rz.uni-bamberg.de/cogsys/dare2del/demonstrator/-/issues/57Number headers only for documentation2020-12-13T19:24:59ZSiebers, MichaelNumber headers only for documentationRegarding the numbering of headers introduced in commit 1dd752e6cf9ca4831eb9c1144ed5c887440dacd1: These are applied to all headlines (in our documentation, auto-generated directory views and the manual). In some places this looks rather ...Regarding the numbering of headers introduced in commit 1dd752e6cf9ca4831eb9c1144ed5c887440dacd1: These are applied to all headlines (in our documentation, auto-generated directory views and the manual). In some places this looks rather ugly, e.g. http://localhost:4444/doc/pldoc/man?section=preddesc.
Could we restrict this formatting to our documentation (directly below `/doc`)?
Implementation note: our documentation is surrounded with a custom wrapper div (id `wiki-wrapper`?)Sebastian SeufertSebastian Seuferthttps://gitlab.rz.uni-bamberg.de/cogsys/dare2del/demonstrator/-/issues/58Support for running as daemon under *nix2021-06-02T12:42:13ZSebastian SeufertSupport for running as daemon under *nixWhen the API is started as daemon it quits/fails.\
Assumption is this is due to SWI's expected environment during runtime / when starting as default REPL with stdio
(case at hand: this [student-project](https://gitlab.rz.uni-bamberg.de/c...When the API is started as daemon it quits/fails.\
Assumption is this is due to SWI's expected environment during runtime / when starting as default REPL with stdio
(case at hand: this [student-project](https://gitlab.rz.uni-bamberg.de/cogsys/its/its-subtraction-webinterface) for which @klaus.stein tried to run a stripped version of the API in a docker container).
@michael.siebers
this might be a somewhat easy fix, c.f. the library-support for http-daemons [here](https://github.com/SWI-Prolog/packages-http/blob/master/http_unix_daemon.pl).\
Do you see any problems I might not see if we used this as wrapper around `web_api.pl`?
-----------------------
Thinking ahead on what might be a problem:
We deliberately ignored anything related to multiuser/threading issues, so could it be possible for the container to be configured s.t. it spawns separate isolated daemon-processes if needed? @klaus.stein \
(I know this is not all that needs to be considered...)Siebers, MichaelSiebers, Michaelhttps://gitlab.rz.uni-bamberg.de/cogsys/dare2del/demonstrator/-/issues/61Setting Content-Length header too high results in Server Error2021-06-14T19:13:35ZSiebers, MichaelSetting Content-Length header too high results in Server Error# Description
Requests to the API may contain a request body. Regardless whether it is required by the endpoint or not, request handling is controlled by the transmitted `Content-Length` header. If no such header is included in the reque...# Description
Requests to the API may contain a request body. Regardless whether it is required by the endpoint or not, request handling is controlled by the transmitted `Content-Length` header. If no such header is included in the request, the API returns `411 Length Required` (for endpoints requiring payload) or ignores the body gracefully (for endpoints requiring no payload). However when a `Content-Length` header is transmitted, there are three cases dependent on the transmitted length (`L`) and the actual body size (`B`).
| Condition | Behavior | Expected Behavior |
| --- | --- | --- |
| `L < B` | Only `L` bytes are read, the rest is discarded. Endpoints expecting a payload operate on the truncated data, succeeding or failing accordingly. Endpoints expecting no payload ignore the body. | as observed |
| `L == B` | The complete body is read. Endpoints expecting a payload operate accordingly. Endpoints expecting no payload ignore the body. | as observed |
| `L > B` | The first `B` bytes are read, then the server waits for the final bytes. Regardless whether the endpoint expects payload or not, the server finally returns `500 Internal Server Error` after timing out (after approx. 1 min.). | to discuss |
## Discussion
The problem is the final case, `L > B`. The server waits for the final bytes which will never arrive. In my opinion, this is no server error but a client-side error. Thus, the resulting status code should be in the 4xx region. Either a general `400 Bad Request` or the specific `408 Request Timeout`? Any thoughts?
## References
- [Failed Pipeline](https://gitlab.rz.uni-bamberg.de/cogsys/dare2del/demonstrator/-/pipelines/24239/failures)
- [Wikipedia Status Code descriptions](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes)https://gitlab.rz.uni-bamberg.de/cogsys/dare2del/demonstrator/-/issues/62HTML error on wrong Content-Length2021-06-12T09:00:31ZSiebers, MichaelHTML error on wrong Content-LengthAccording to #28 all error messages are expected to be JSON.
When transmitting a non-numeric Content-Length header, the API correctly returns '400 Bad Request`. However, the transmitted error message is not a JSON object but an HTML docu...According to #28 all error messages are expected to be JSON.
When transmitting a non-numeric Content-Length header, the API correctly returns '400 Bad Request`. However, the transmitted error message is not a JSON object but an HTML document.
**Evidence**: Test `bg/add: Valid error response body` belonging to Job `system_test:robust against wrong payload` in [Pipeline #24261](https://gitlab.rz.uni-bamberg.de/cogsys/dare2del/demonstrator/-/pipelines/24261/test_report)