sorting by is_available #2827
No reviewers
Labels
No labels
1week
2weeks
Failed compliance check
IP cameras
NATS
Possible security concern
Review effort 1/5
Review effort 2/5
Review effort 3/5
Review effort 4/5
Review effort 5/5
UI
aardvark
accessibility
amd64
api
arm64
auth
back-end
bgp
blog
bug
build
checkers
ci-cd
cleanup
cnpg
codex
core
dependencies
device-management
documentation
duplicate
dusk
ebpf
enhancement
eta 1d
eta 1hr
eta 3d
eta 3hr
feature
fieldsurvey
github_actions
go
good first issue
help wanted
invalid
javascript
k8s
log-collector
mapper
mtr
needs-triage
netflow
network-sweep
observability
oracle
otel
plug-in
proton
python
question
reddit
redhat
research
rperf
rperf-checker
rust
sdk
security
serviceradar-agent
serviceradar-agent-gateway
serviceradar-web
serviceradar-web-ng
siem
snmp
sysmon
topology
ubiquiti
wasm
wontfix
zen-engine
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
carverauto/serviceradar!2827
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "refs/pull/2827/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from GitHub pull request.
Original GitHub pull request: #2661
Original author: @mfreeman451
Original URL: https://github.com/carverauto/serviceradar/pull/2661
Original created: 2026-02-02T01:35:38Z
Original updated: 2026-02-02T01:37:26Z
Original head: carverauto/serviceradar:2643-featweb-ng-device-inventory-should-always-sort-devices-by-is_available-true
Original base: staging
Original merged: 2026-02-02T01:36:23Z by @mfreeman451
User description
IMPORTANT: Please sign the Developer Certificate of Origin
Thank you for your contribution to ServiceRadar. Please note, when contributing, the developer must include
a DCO sign-off statement indicating the DCO acceptance in one commit message. Here
is an example DCO Signed-off-by line in a commit message:
Describe your changes
Issue ticket number and link
Code checklist before requesting a review
PR Type
Enhancement
Description
Add
is_availableas sortable field for devices in SRQLChange default device sort from
last_seentois_availableRefactor ordering logic to support primary and secondary sort fields
Implement intelligent default ordering:
is_availabledesc, thenipasc, thenuidascDiagram Walkthrough
File Walkthrough
catalog.ex
Change default device sort fieldweb-ng/lib/serviceradar_web_ng_web/srql/catalog.ex
last_seentois_availablebuilder.ex
Add is_available to allowed sort fieldsweb-ng/lib/serviceradar_web_ng_web/srql/builder.ex
is_availableto allowed sort fields for devicesnormalize_sort_fieldfunctiondevices.rs
Refactor ordering logic and add is_available supportrust/srql/src/query/devices.rs
Inettype import for IP address handlingapply_orderingfunction to support multiple sort clauseswith primary and secondary ordering
apply_primary_orderandapply_secondary_orderhelper functionsis_available(desc), thenip(asc), then
uid(asc)is_availableandipfields with proper SQL typecasting
Imported GitHub PR comment.
Original author: @qodo-code-review[bot]
Original URL: https://github.com/carverauto/serviceradar/pull/2661#issuecomment-3832478759
Original created: 2026-02-02T01:36:12Z
PR Compliance Guide 🔍
Below is a summary of compliance checks for this PR:
No security concerns identified
No security vulnerabilities detected by AI analysis. Human verification advised for critical code.🎫 #2643
network/IP).
Codebase context is not defined
Follow the guide to enable codebase context checks.
Generic: Comprehensive Audit Trails
Objective: To create a detailed and reliable record of critical system actions for security analysis
and compliance.
Status: Passed
Generic: Meaningful Naming and Self-Documenting Code
Objective: Ensure all identifiers clearly express their purpose and intent, making code
self-documenting
Status: Passed
Generic: Secure Error Handling
Objective: To prevent the leakage of sensitive system information through error messages while
providing sufficient detail for internal debugging.
Status: Passed
Generic: Secure Logging Practices
Objective: To ensure logs are useful for debugging and auditing without exposing sensitive
information like PII, PHI, or cardholder data.
Status: Passed
Generic: Robust Error Handling and Edge Case Management
Objective: Ensure comprehensive error handling that provides meaningful context and graceful
degradation
Status:
Inet cast failure: Ordering by
ipusesNULLIF(ip, '')::inetwhich can raise a database error atruntime if the stored
ipvalue is non-empty but not a valid inet string, and this edgecase is not handled in the query logic.
Referred Code
Generic: Security-First Input Validation and Data Handling
Objective: Ensure all data inputs are validated, sanitized, and handled securely to prevent
vulnerabilities
Status:
Raw SQL ordering: The new ordering logic introduces raw SQL fragments (e.g.,
coalesce(is_available, false)and
NULLIF(ip, '')::inet) and correctness/safety depends on upstream validationof order fields and on column contents always being castable, which is not verifiable from
this diff alone.
Referred Code
Compliance status legend
🟢 - Fully Compliant🟡 - Partial Compliant
🔴 - Not Compliant
⚪ - Requires Further Human Verification
🏷️ - Compliance label
Imported GitHub PR comment.
Original author: @qodo-code-review[bot]
Original URL: https://github.com/carverauto/serviceradar/pull/2661#issuecomment-3832480686
Original created: 2026-02-02T01:37:26Z
PR Code Suggestions ✨
Explore these optional code suggestions:
Only add UID if not seen
Track if
uidis used in sorting and conditionally add the defaultuidsort orderonly if it has not been specified, preventing duplicate clauses.
rust/srql/src/query/devices.rs [1110-1128]
[To ensure code accuracy, apply this suggestion manually]Suggestion importance[1-10]: 7
__
Why: The suggestion correctly identifies and fixes a bug where a redundant
ORDER BYclause foruidis added, improving the correctness and efficiency of the generated SQL.Refactor duplicated Rust ordering logic
Refactor the duplicated logic in
apply_primary_orderandapply_secondary_orderinto a single, generic function or macro to improve maintainability. The only
difference between them is the call to
order()versusthen_order_by().Examples:
rust/srql/src/query/devices.rs [1133-1243]
Solution Walkthrough:
Before:
After:
Suggestion importance[1-10]: 6
__
Why: The suggestion correctly identifies significant code duplication in the new
apply_primary_orderandapply_secondary_orderfunctions, which impacts maintainability.