Skip to content

fix: use parseAsSafeArrayOf for logs page array query params to handle special characters in URLs - #4761

Merged
akshaydeo merged 1 commit into
mainfrom
fix/use-parse-as-safe-array-logs-query-params
Jun 29, 2026
Merged

akshaydeo merged 1 commit into
mainfrom
fix/use-parse-as-safe-array-logs-query-params

Conversation

@impoiler

Copy link
Copy Markdown
Contributor

Cherry-picked from dev: 99ae847

…dle special characters in URLs (#4714)

## Summary

Array-type query parameters in the logs page (models, providers, etc.) were not using the safe URI-encoding parser, meaning values containing characters like `://` (e.g. model names such as `gpt://host/model`) could be misinterpreted as path or query delimiters by TanStack Router. This introduces `parseAsSafeArrayOf` and applies it consistently across all array filters.

## Changes

- Added `parseAsSafeArrayOf` to `queryParamsParser.ts` by composing `parseAsArrayOf` with the existing `parseAsSafeString` parser, ensuring full URI-encoding for comma-separated filter values.
- Replaced all usages of `parseAsArrayOf(parseAsString)` in the logs page with `parseAsSafeArrayOf` so that array filters (models, providers, aliases, status, etc.) benefit from the same encoding guarantees as string filters.
- Added unit tests for both `parseAsSafeString` and `parseAsSafeArrayOf` to verify round-trip correctness with model names containing `://`.

## Type of change

- [x] Bug fix

## Affected areas

- [x] UI (React)

## How to test

```sh
cd ui
pnpm i || npm i
pnpm test || npm test
pnpm build || npm run build
```

To manually verify, navigate to the logs page and apply a filter using a model name containing `://` (e.g. `gpt://host/model`). Confirm the URL encodes correctly and the filter persists on page reload without routing errors.

## Screenshots/Recordings

N/A

## Breaking changes

- [x] No

## Related issues

#4603

## Security considerations

No security implications. This change only affects URL query parameter encoding in the UI.

## Checklist

- [ ] I read `docs/contributing/README.md` and followed the guidelines
- [x] I added/updated tests where appropriate
- [ ] I updated documentation where needed
- [x] I verified builds succeed (Go and UI)
- [ ] I verified the CI pipeline passes locally if applicable
@mintlify

mintlify Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
Bifrost 🟡 Building Jun 29, 2026, 6:59 AM

💡 Tip: Enable Workflows to automatically generate PRs for you.

@coderabbitai

coderabbitai Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 1ca41bd8-e9db-417f-af8c-00b5fefcbc41

📥 Commits

Reviewing files that changed from the base of the PR and between 056452f and 2cc19f2.

📒 Files selected for processing (3)
  • ui/app/workspace/logs/page.tsx
  • ui/lib/queryParamsParser.test.ts
  • ui/lib/queryParamsParser.ts

📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes

    • Improved handling of URL filters on the logs workspace page, making query parameters more reliable for lists of values and special characters.
    • Fixed encoding of selected values so links can safely preserve items with unusual text without breaking the page state.
  • Tests

    • Added coverage to verify query values round-trip correctly and stay safely encoded.

Walkthrough

parseAsSafeString is updated to encode/decode values with encodeURIComponent/decodeURIComponent (with fallback). A new parseAsSafeArrayOf helper is added using parseAsArrayOf(parseAsSafeString). The logs page switches all array filter URL params to use parseAsSafeArrayOf. Tests verify round-trip behavior and absence of :// in serialized output.

Safe Array Query Param Parser

Layer / File(s) Summary
parseAsSafeString and parseAsSafeArrayOf implementation
ui/lib/queryParamsParser.ts, ui/lib/queryParamsParser.test.ts
Adds encodeURIComponent/decodeURIComponent with try/catch fallback to parseAsSafeString, exports parseAsSafeArrayOf as parseAsArrayOf(parseAsSafeString), and tests round-trip serialization for strings with :// patterns.
Logs page migration to safe array parsers
ui/app/workspace/logs/page.tsx
Replaces parseAsArrayOf(parseAsString) with parseAsSafeArrayOf for all array filter params (providers, models, aliases, status, stop_reasons, objects, selected_key_ids, virtual_key_ids, routing_rule_ids, routing_engine_used, user_ids, team_ids, customer_ids, business_unit_ids, cache_hit_types) and updates imports.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

  • maximhq/bifrost#4714: Directly modifies the same files (ui/lib/queryParamsParser.ts, ui/lib/queryParamsParser.test.ts, ui/app/workspace/logs/page.tsx) with the same parseAsSafeArrayOf migration.

Poem

🐇 Hopping through URL fields with glee,
No :// shall pass, safe as can be!
Encode and decode with a fluffy paw,
Round-trip tested, no parsing flaw.
The logs page filtered, crisp and bright —
This bunny made the params right! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is only a cherry-pick note and omits the required summary, changes, testing, and checklist sections. Fill in the template sections: summary, changes, type, affected areas, testing, screenshots, breaking changes, related issues, security, and checklist.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly states the main fix: safer parsing for logs page array query params with special-character handling.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/use-parse-as-safe-array-logs-query-params

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.
  • The new parser keeps decoded string arrays flowing into the existing logs filter and API paths.
  • The added tests cover the special-character model URL case this change targets.

Important Files Changed

Filename Overview
ui/lib/queryParamsParser.ts Adds a safe array parser by composing the existing safe string parser with nuqs array parsing.
ui/app/workspace/logs/page.tsx Uses the safe array parser for logs-page filter state stored in the URL.
ui/lib/queryParamsParser.test.ts Adds focused roundtrip coverage for safe string and safe array query parsing.

Reviews (1): Last reviewed commit: "fix: use `parseAsSafeArrayOf` for logs p..." | Re-trigger Greptile

akshaydeo commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Merge activity

  • Jun 29, 9:56 AM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Jun 29, 9:57 AM UTC: @akshaydeo merged this pull request with Graphite.

@akshaydeo
akshaydeo merged commit a1fc54c into main Jun 29, 2026
22 checks passed
@akshaydeo
akshaydeo deleted the fix/use-parse-as-safe-array-logs-query-params branch June 29, 2026 09:57
R-droid101 pushed a commit to R-droid101/bifrost that referenced this pull request Jul 1, 2026
…e special characters in URLs (maximhq#4761)

Cherry-picked from dev: 99ae847
akhsaul pushed a commit to akhsaul/bifrost that referenced this pull request Aug 27, 2026
…e special characters in URLs (maximhq#4761)

Cherry-picked from dev: 1789a957bc7e74b00e093d83e73469571824d276
occcat pushed a commit to occcat/bifrost that referenced this pull request Sep 2, 2026
…e special characters in URLs (maximhq#4761)

Cherry-picked from dev: 99ae847
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