fix(core): fix base query to return asset data when httpx failed#281
fix(core): fix base query to return asset data when httpx failed#281
Conversation
Summary of ChangesHello @mizhm, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses an issue where certain assets were not being displayed or retrieved due to overly strict filtering based on status codes. The changes relax these filtering conditions in the backend and ensure that the frontend UI for asset details dynamically adapts to the presence of network information, preventing empty sections. Additionally, dependency metadata has been updated for improved package management. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request fixes an issue with the asset query by correctly filtering assets based on their status code, ensuring that assets with a NULL status code are included. It also includes a related UI fix in the asset detail view to conditionally render the 'Network' section, preventing an empty section from being displayed when TLS data is not available. My review includes a suggestion to further refine this UI logic to avoid rendering the section if specific network details are missing.
| {tls && ( | ||
| <section> | ||
| <h3 className="font-bold text-indigo-500 flex items-center gap-2 sm:gap-3 mb-3 sm:mb-4"> | ||
| <Network size={20} className="text-indigo-500" /> Network | ||
| </h3> | ||
| <div className="grid grid-cols-1 md:grid-cols-2 gap-y-3 sm:gap-y-4 gap-x-6 sm:gap-x-8"> | ||
| {tls?.host && ( | ||
| <div> | ||
| <span className="block mb-1">Host</span> | ||
| <span className="">{tls.host}</span> | ||
| </div> | ||
| )} | ||
| {/* Port from TLS data, but presented in Network section */} | ||
| {tls?.port && ( | ||
| <div> | ||
| <span className="block mb-1">Port</span> | ||
| <span className="">{tls.port}</span> | ||
| </div> | ||
| )} | ||
| </div> | ||
| </section> | ||
| )} |
There was a problem hiding this comment.
The current check tls && is an improvement, but it might still render an empty "Network" section if the tls object exists but both host and port are missing. To prevent this, it's better to check for the presence of tls.host or tls.port directly.
{(tls?.host || tls?.port) && (
<section>
<h3 className="font-bold text-indigo-500 flex items-center gap-2 sm:gap-3 mb-3 sm:mb-4">
<Network size={20} className="text-indigo-500" /> Network
</h3>
<div className="grid grid-cols-1 md:grid-cols-2 gap-y-3 sm:gap-y-4 gap-x-6 sm:gap-x-8">
{tls.host && (
<div>
<span className="block mb-1">Host</span>
<span className="">{tls.host}</span>
</div>
)}
{/* Port from TLS data, but presented in Network section */}
{tls.port && (
<div>
<span className="block mb-1">Port</span>
<span className="">{tls.port}</span>
</div>
)}
</div>
</section>
)}
There was a problem hiding this comment.
Pull request overview
This PR adjusts asset querying so assets/services without a populated HTTP status code are no longer filtered out, and updates the asset detail UI to avoid rendering empty network details when TLS data is absent.
Changes:
- Updates the core assets query to allow
NULLstatus codes while still excluding status code0. - Removes a redundant status-code filter from
getAssetById()(now covered by the base query logic). - Conditionally renders the “Network” section in the console asset detail only when TLS data exists.
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| package-lock.json | Lockfile regenerated (large metadata-only churn, including many peer: true flags). |
| core-api/src/modules/assets/assets.service.ts | Changes base query status-code filtering to include NULL and removes redundant per-ID filtering. |
| console/src/pages/assets/components/asset-detail.tsx | Guards “Network” section rendering behind presence of tls. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| .andWhere( | ||
| new Brackets((qb) => { | ||
| qb.where('"statusCodeAssets"."statusCode" IS NULL').orWhere( | ||
| '"statusCodeAssets"."statusCode" != 0', | ||
| ); | ||
| }), | ||
| ); |
There was a problem hiding this comment.
The new base filter (statusCode IS NULL OR statusCode != 0) means queries that group/filter by status code can now include a NULL statusCode bucket (e.g., getStatusCodeAssets() groups on "statusCodeAssets"."statusCode"). This can surface rows with statusCode: null to the console, and the UI then uses row.statusCode as a filter value, which can result in statusCodes=[null] requests.
Consider keeping this base query change for asset listing, but explicitly exclude NULL status codes in the status-code aggregation endpoint (or map NULL to a well-defined sentinel) so the status-code facet remains valid and clickable.
l1ttps
left a comment
There was a problem hiding this comment.
Thanks @mizhm for this fix!
The changes look good - relaxing the status code filter to include assets with NULL status codes makes sense since some assets may not have HTTP responses yet. The frontend improvement to conditionally render the Network section also improves UX by avoiding empty sections.
One minor note: the package-lock.json changes are quite extensive (peer dependency flags). In the future, it might be worth separating dependency updates into a dedicated PR for cleaner history, but this doesn't block the merge.
Great work!
No description provided.