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

Avoid uncaught fatal errors in REST API if vocabulary ID not found #1231

Merged
merged 1 commit into from
Nov 2, 2021

Conversation

osma
Copy link
Member

@osma osma commented Nov 2, 2021

Fixes #1170

This is a similar fix as #1215, but for the REST API.

For an URL like this: http://localhost/Skosmos/rest/v1/koko2/data?format=text/turtle

(note that there is no vocabulary with the id koko2 defined in config.ttl)

it prevents uncaught fatal errors like this:

[Tue Nov 02 09:49:37.020140 2021] [php7:error] [pid 175327] [client 127.0.0.1:53116] PHP Fatal error:  Uncaught ValueError: Vocabulary id 'koko2' not found in configuration. in /var/www/html/Skosmos/model/Model.php:420\nStack trace:\n#0 /var/www/html/Skosmos/model/Request.php(246): Model->getVocabulary()\n#1 /var/www/html/Skosmos/rest.php(46): Request->setVocab()\n#2 {main}\n  thrown in /var/www/html/Skosmos/model/Model.php on line 420

Instead a 404 error is produced, like this:

404 Not Found : Vocabulary id 'koko2' not found.

@osma osma added this to the 2.13 milestone Nov 2, 2021
@osma osma self-assigned this Nov 2, 2021
@sonarcloud
Copy link

sonarcloud bot commented Nov 2, 2021

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@codecov
Copy link

codecov bot commented Nov 2, 2021

Codecov Report

Merging #1231 (09fa432) into master (5cf55f0) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##             master    #1231   +/-   ##
=========================================
  Coverage     68.36%   68.36%           
  Complexity     1619     1619           
=========================================
  Files            32       32           
  Lines          3973     3973           
=========================================
  Hits           2716     2716           
  Misses         1257     1257           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5cf55f0...09fa432. Read the comment docs.

@osma osma merged commit d12c2d3 into master Nov 2, 2021
@osma osma deleted the issue1170-rest-fatal-error-vocab-id-not-found branch November 2, 2021 08:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PHP fatal error if the requested vocabulary id is not found
1 participant