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

fix(confighttp): do not return 200 on errors #3385

Merged
merged 8 commits into from
Jan 10, 2025

Conversation

ReenigneArcher
Copy link
Member

@ReenigneArcher ReenigneArcher commented Nov 10, 2024

Description

  • Return 400 status code on config API errors
  • Add default_resource for requests that are not GET
  • Remove trailing commas in API examples
  • Clarify how index works when saving an app
  • Change xml responses to json
  • Add grouped tab code examples to API docs

TODO:

  • fix fail guards, per @FrogTheFrog
  • add tabbed examples for each endpoint in docs. e.g. curl, python, javascript, powershell
  • trying to delete app way out of index range shows as success
    >curl -u user:pass -X DELETE -k https://localhost:47990/api/apps/5000
    {
        "status": "true"
    }
    
    Note: existing check was useless since it could never actually be fired ( < 0 is not possible due to the regex of the endpoint), instead changed it to a clamp and checked the upper bounds.

Screenshot

image
image
image

Issues Fixed or Closed

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Dependency update (updates to dependencies)
  • Documentation update (changes to documentation)
  • Repository update (changes to repository files, e.g. .github/...)

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated the in code docstring/documentation-blocks for new or existing methods/components

@ReenigneArcher ReenigneArcher force-pushed the fix/confighttp/do-not-return-200-on-errors branch from a18aef8 to eec6b6c Compare November 10, 2024 00:04
Copy link

codecov bot commented Nov 10, 2024

Codecov Report

Attention: Patch coverage is 0% with 125 lines in your changes missing coverage. Please review.

Project coverage is 8.45%. Comparing base (80ecf19) to head (015c0ad).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
src/confighttp.cpp 0.00% 124 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##           master   #3385      +/-   ##
=========================================
+ Coverage    8.44%   8.45%   +0.01%     
=========================================
  Files          90      90              
  Lines       16074   16054      -20     
  Branches     7636    7626      -10     
=========================================
  Hits         1357    1357              
- Misses      12237   14197    +1960     
+ Partials     2480     500    -1980     
Flag Coverage Δ
Linux 9.17% <0.00%> (+0.01%) ⬆️
Windows 6.19% <0.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/confighttp.cpp 0.00% <0.00%> (ø)

... and 32 files with indirect coverage changes

@ReenigneArcher ReenigneArcher force-pushed the fix/confighttp/do-not-return-200-on-errors branch from eec6b6c to f65d517 Compare November 10, 2024 00:23
@ReenigneArcher ReenigneArcher force-pushed the fix/confighttp/do-not-return-200-on-errors branch from f65d517 to 45de0cc Compare January 8, 2025 02:37
@ReenigneArcher ReenigneArcher added the help wanted Extra attention is needed label Jan 8, 2025
@ReenigneArcher ReenigneArcher added this to the stable release milestone Jan 8, 2025
@ReenigneArcher ReenigneArcher force-pushed the fix/confighttp/do-not-return-200-on-errors branch from 45de0cc to 78b043a Compare January 9, 2025 00:55
@ReenigneArcher ReenigneArcher removed the help wanted Extra attention is needed label Jan 9, 2025
@ReenigneArcher ReenigneArcher force-pushed the fix/confighttp/do-not-return-200-on-errors branch 3 times, most recently from 10e6d57 to 2bf4c22 Compare January 9, 2025 04:53
@ReenigneArcher ReenigneArcher marked this pull request as ready for review January 9, 2025 04:54
@ReenigneArcher ReenigneArcher force-pushed the fix/confighttp/do-not-return-200-on-errors branch from 2bf4c22 to a7c5ed9 Compare January 9, 2025 05:02
@LizardByte LizardByte deleted a comment from sonarqubecloud bot Jan 9, 2025
@ReenigneArcher ReenigneArcher force-pushed the fix/confighttp/do-not-return-200-on-errors branch from a7c5ed9 to d945065 Compare January 9, 2025 05:07
src/confighttp.cpp Outdated Show resolved Hide resolved
src/confighttp.cpp Outdated Show resolved Hide resolved
src/confighttp.cpp Outdated Show resolved Hide resolved
src/confighttp.cpp Outdated Show resolved Hide resolved
docs/api.js Outdated Show resolved Hide resolved
@ReenigneArcher ReenigneArcher force-pushed the fix/confighttp/do-not-return-200-on-errors branch 3 times, most recently from 2c0b122 to 3c9659f Compare January 9, 2025 18:06
@ReenigneArcher
Copy link
Member Author

Quality Gate Failed Quality Gate failed

Failed conditions 2 New issues 2 New Code Smells (required ≤ 0)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

std::format is not available in gcc 11

@ReenigneArcher ReenigneArcher force-pushed the fix/confighttp/do-not-return-200-on-errors branch 4 times, most recently from ac92ff6 to 10e2048 Compare January 9, 2025 22:46
@ReenigneArcher
Copy link
Member Author

I guess we can't return valid int/boolean json?

{
    "status_code": 400,
    "status": false,
    "error": "index out of range, max index is 1"
}

instead of:

{
    "status_code": "400",
    "status": "false",
    "error": "index out of range, max index is 1"
}

Copy link
Collaborator

@FrogTheFrog FrogTheFrog left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mostly looked at cpp code. Other files seem fine.

src/confighttp.cpp Outdated Show resolved Hide resolved
src/confighttp.cpp Outdated Show resolved Hide resolved
src/confighttp.cpp Outdated Show resolved Hide resolved
src/confighttp.cpp Outdated Show resolved Hide resolved
src/confighttp.cpp Show resolved Hide resolved
src/confighttp.cpp Outdated Show resolved Hide resolved
src/confighttp.cpp Outdated Show resolved Hide resolved
src/confighttp.cpp Outdated Show resolved Hide resolved
src/confighttp.cpp Show resolved Hide resolved
@ReenigneArcher ReenigneArcher force-pushed the fix/confighttp/do-not-return-200-on-errors branch from 1e551be to b2c70ad Compare January 10, 2025 14:31
src/confighttp.cpp Outdated Show resolved Hide resolved
src/confighttp.cpp Outdated Show resolved Hide resolved
src/confighttp.cpp Outdated Show resolved Hide resolved
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
4 New issues
4 New Code Smells (required ≤ 0)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@ReenigneArcher ReenigneArcher merged commit 40ac718 into master Jan 10, 2025
34 of 35 checks passed
@ReenigneArcher ReenigneArcher deleted the fix/confighttp/do-not-return-200-on-errors branch January 10, 2025 20:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Beta API: POST /api/apps returns 200 OK on invalid input JSON
2 participants