Skip to content

feat(api): add application image endpoint#4627

Merged
ReenigneArcher merged 8 commits intoLizardByte:masterfrom
cilps:feat/api/add-application-image-endpoint
Jan 27, 2026
Merged

feat(api): add application image endpoint#4627
ReenigneArcher merged 8 commits intoLizardByte:masterfrom
cilps:feat/api/add-application-image-endpoint

Conversation

@cilps
Copy link
Contributor

@cilps cilps commented Jan 25, 2026

Introduces a new API endpoint that returns a application's image.

Description

Creates a new API route and function. Adds an error_message argument to the not_found function in confighttp.cpp. Updated docs to include new endpoint.

Screenshot

Issues Fixed or Closed

Resolves https://discord.com/channels/804382334370578482/1464609795012169988

Roadmap Issues

Type of Change

  • feat: New feature (non-breaking change which adds functionality)
  • fix: Bug fix (non-breaking change which fixes an issue)
  • docs: Documentation only changes
  • style: Changes that do not affect the meaning of the code (white-space, formatting, missing semicolons, etc.)
  • refactor: Code change that neither fixes a bug nor adds a feature
  • perf: Code change that improves performance
  • test: Adding missing tests or correcting existing tests
  • build: Changes that affect the build system or external dependencies
  • ci: Changes to CI configuration files and scripts
  • chore: Other changes that don't modify src or test files
  • revert: Reverts a previous commit
  • BREAKING CHANGE: Introduces a breaking change (can be combined with any type above)

Checklist

  • Code follows the style guidelines of this project
  • Code has been self-reviewed
  • Code has been commented, particularly in hard-to-understand areas
  • Code docstring/documentation-blocks for new or existing methods/components have been added or updated
  • Unit tests have been added or updated for any new or modified functionality

AI Usage

  • None: No AI tools were used in creating this PR
  • Light: AI provided minor assistance (formatting, simple suggestions)
  • Moderate: AI helped with code generation or debugging specific parts
  • Heavy: AI generated most or all of the code changes

@ReenigneArcher ReenigneArcher mentioned this pull request Jan 26, 2026
34 tasks
@ReenigneArcher

This comment was marked as resolved.

@cilps

This comment was marked as resolved.

@cilps

This comment was marked as resolved.

@cilps cilps requested a review from ReenigneArcher January 27, 2026 15:45
cilps and others added 7 commits January 27, 2026 15:06
Introduces a new API endpoint that returns a application's image. Adds an error_message argument to the not_found function in confighttp.cpp.
moved the app index checking (wether an application with the given index actually exists) into a reusable function. changed apps_node to apps in deleteApp
Added png validation (check_valid_png function is 100% AI generated!), fixed cover images in the cover directory (e.g a image uploaded with the uploadCover function) and default images (the steam.png and desktop.png).
Used the shorter fs::path alias instead of std::filesystem::path. Also removed unnecesary path conversion.
Moved PNG signature validation logic from confighttp.cpp to process.cpp as check_valid_png, and updated getCover to use validate_app_image_path for image path resolution and validation. Added extensive unit tests for check_valid_png and validate_app_image_path in test_process.cpp. Defined DEFAULT_APP_IMAGE_PATH in process.h and improved error handling and logging for invalid or unreadable PNG files.
@ReenigneArcher ReenigneArcher force-pushed the feat/api/add-application-image-endpoint branch from d3de613 to 03e22a2 Compare January 27, 2026 20:26
@ReenigneArcher
Copy link
Member

I made a few tweaks to this PR.

  1. It re-uses cover image logic from process.cpp/h, so it will return the same as what is provided to Moonlight. This will be the default image if no image is specified. It also means we don't have to specifically check all the directories like the cover directory, assets directory, etc. as this logic is already defined.
  2. Moves the png validation logic to the process.cpp/h, and also uses it when Moonlight requests the cover now.
  3. Adds some unit tests.

Added documentation for the error_message parameter in the not_found function to clarify its purpose in the HTTP 404 response.
@codecov
Copy link

codecov bot commented Jan 27, 2026

Bundle Report

Bundle size has no change ✅

@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
2 New issues
1 Security Hotspot
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

@codecov
Copy link

codecov bot commented Jan 27, 2026

Codecov Report

❌ Patch coverage is 21.05263% with 60 lines in your changes missing coverage. Please review.
✅ Project coverage is 15.46%. Comparing base (2141917) to head (d026479).
⚠️ Report is 1 commits behind head on master.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/confighttp.cpp 0.00% 45 Missing and 10 partials ⚠️
src/process.cpp 76.19% 2 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4627      +/-   ##
==========================================
+ Coverage   15.43%   15.46%   +0.02%     
==========================================
  Files          94       94              
  Lines       19178    19235      +57     
  Branches     8861     8898      +37     
==========================================
+ Hits         2960     2974      +14     
+ Misses      14429    14393      -36     
- Partials     1789     1868      +79     
Flag Coverage Δ
Archlinux 11.62% <20.00%> (+0.14%) ⬆️
FreeBSD-14.3-aarch64 ?
FreeBSD-14.3-amd64 13.75% <9.58%> (+0.02%) ⬆️
Homebrew-ubuntu-22.04 13.93% <20.00%> (+0.14%) ⬆️
Linux-AppImage 11.94% <20.00%> (+0.15%) ⬆️
Windows-AMD64 13.50% <20.00%> (+0.14%) ⬆️

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

Files with missing lines Coverage Δ
src/process.h 22.22% <ø> (ø)
src/process.cpp 7.90% <76.19%> (+6.61%) ⬆️
src/confighttp.cpp 0.00% <0.00%> (ø)

... and 40 files with indirect coverage changes

@ReenigneArcher ReenigneArcher merged commit 76b3a85 into LizardByte:master Jan 27, 2026
52 of 54 checks passed
@cilps cilps deleted the feat/api/add-application-image-endpoint branch January 28, 2026 12:53
@cilps
Copy link
Contributor Author

cilps commented Jan 28, 2026

Why did you add the check_content_type function in the getCover function? It checks for the Content-Type application/json header, which is weird because you don't have to send any JSON in the request body to use this endpoint.

@ReenigneArcher
Copy link
Member

I'm fixing it in #4631

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.

2 participants