zakariamaaraki / RemoteCodeCompiler

An online code compiler supporting 11 programming languages (Java, Kotlin, Scala, C, C++, C#, Golang, Python, Ruby, Rust and Haskell) for competitive programming and coding interviews.
GNU General Public License v3.0
157 stars 52 forks source link

Dynamic code does not work as documented in README #48

Closed rpatidar closed 6 months ago

rpatidar commented 6 months ago

I am trying to execute the dynamic code via the API but it looks like when i make the call it still try to look into the predefined problem repository. am i missing something or this is by design ?

 curl 'http://localhost:8080/api/execute' \
  -H 'Accept: */*' \
  -H 'Accept-Language: en-US,en;q=0.9' \
  -H 'Connection: keep-alive' \
  -H 'Content-type: application/json; charset=UTF-8' \
  -H 'DNT: 1' \
  -H 'Origin: http://localhost:8080' \
  -H 'Referer: http://localhost:8080/problem/1' \
  -H 'Sec-Fetch-Dest: empty' \
  -H 'Sec-Fetch-Mode: cors' \
  -H 'Sec-Fetch-Site: same-origin' \
  -H 'User-Agent: Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Mobile Safari/537.36' \
  -H 'sec-ch-ua: "Chromium";v="124", "Google Chrome";v="124", "Not-A.Brand";v="99"' \
  -H 'sec-ch-ua-mobile: ?1' \
  -H 'sec-ch-ua-platform: "Android"' \
  --data-raw '{"sourceCode":"// Java code here\npublic class main {\n    public static void main(String[] args) {\n        System.out.println(\"YES\");\n    }\n}","language":"JAVA", "testCases": { "test1" : {"input": "RAJESH", "expectedOutput": "RAJESH"}}}, "timeLimit": 15, "memoryLimit": 500'
{"timestamp":"2024-04-26T01:47:49.147+00:00","status":404,"error":"Not Found","message":"A problem with id 0 does not exist","path":"/api/execute","errorCode":"NOT_FOUND","errorType":"WARNING","isRetryableError":false,"retryIn":-1}%

Error:

{"timestamp":"2024-04-26T01:47:49.147+00:00","status":404,"error":"Not Found","message":"A problem with id 0 does not exist","path":"/api/execute","errorCode":"NOT_FOUND","errorType":"WARNING","isRetryableError":false,"retryIn":-1}%
rpatidar commented 6 months ago

found i was hitting wrong endpoint

curl  'http://localhost:8080/api/compile/json'  -X POST -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:125.0) Gecko/20100101 Firefox/125.0' -H 'Accept: */*' -H 'Accept-Language: en-US,en;q=0.5' -H 'Accept-Encoding: gzip, deflate, br' -H 'Content-Type: application/json; charset=UTF-8' -H 'Referer: http://localhost:8080/problem/1' -H 'Origin: http://localhost:8080' -H 'Sec-Fetch-Dest: empty' -H 'Sec-Fetch-Mode: cors' -H 'Sec-Fetch-Site: same-origin' -H 'Connection: keep-alive' -H 'Cookie: csrftoken=jpFoTKvcdkdlEqAXIFWy01Ni4FGYqSHIPU6EdOrMSQciYoWLq6Sq8anKGErSpnzZ; _ga_Z4KXEBY4VP=GS1.1.1693626148.2.1.1693626222.60.0.0; _ga=GA1.1.536432755.1693448373; fusra_session_id=4d440183-4faf-4e39-8cf4-28fa7c03cf49; intercom-device-id-y10e7138=080b5c46-95b6-4c59-8f5c-33360dc6c0b4; ajs_anonymous_id=74ae1ae5-6ed5-4821-b0a1-f679e5164f69; ajs_user_id=7c5ec2f70f412cb5d62a0ee073ab891d1d296543fc3afa46ba2865ec0a39d42c' --data-raw '{"sourcecode":"// Java code here\npublic class main {\n    public static void main(String[] args) {\n        System.out.println(\"NO\");\n    }\n}","language":"JAVA", "testCases": {"test1" : {"input" : "", "expectedOutput" : "YES"}}}'

but this gives me

{"error":null,"execution":{"verdict":"Out Of Memory","statusCode":400,"error":"./entrypoint-test1.sh: line 4:     8 Segmentation fault      timeout -s SIGTERM 0 java -Djava.security.manager -Djava.security.policy=./security.policy main\n","testCasesResult":{"test1":{"verdict":"Out Of Memory","verdictStatusCode":400,"output":"","error":"./entrypoint-test1.sh: line 4:     8 Segmentation fault      timeout -s SIGTERM 0 java -Djava.security.manager -Djava.security.policy=./security.policy main\n","expectedOutput":"YES","executionDuration":6,"outputDiff":"<add>YES</add>"}},"compilationDuration":289,"averageExecutionDuration":6.0,"timeLimit":0,"memoryLimit":0,"language":"JAVA","dateTime":"2024-04-26T11:57:59.646843"}}%
rpatidar commented 6 months ago

all issue resolved. awesome product.

 curl  'http://localhost:8080/api/compile/json'  -X POST  -H 'Content-Type: application/json; charset=UTF-8'  --data-raw '{"sourcecode":"// Java code here\npublic class main {\n    public static void main(String[] args) {\n        System.out.println(\"NO\");\n    }\n}","language":"JAVA", "testCases": {"test1" : {"input" : "", "expectedOutput" : "NO"}}, "memoryLimit" : 500 }'

{"error":null,"execution":{"verdict":"Accepted","statusCode":100,"error":"","testCasesResult":{"test1":{"verdict":"Accepted","verdictStatusCode":100,"output":"NO\n","error":"","expectedOutput":"NO","executionDuration":1780,"outputDiff":null}},"compilationDuration":284,"averageExecutionDuration":1780.0,"timeLimit":0,"memoryLimit":500,"language":"JAVA","dateTime":"2024-04-26T12:08:38.771927"}}%
zakariamaaraki commented 6 months ago

Thanks for the feedback. Yes, about your first comment: you were hitting the wrong endpoint. For the second one: you were setting memory limit and time limit to 0.

zakariamaaraki commented 6 months ago

Can i close the issue?