Skip to content

refactor(api): use createHono and request-id logging in config_builder#2086

Merged
riderx merged 2 commits into
mainfrom
fix/config-builder-createhono-logging
May 10, 2026
Merged

refactor(api): use createHono and request-id logging in config_builder#2086
riderx merged 2 commits into
mainfrom
fix/config-builder-createhono-logging

Conversation

@WcaleNieWolny
Copy link
Copy Markdown
Contributor

@WcaleNieWolny WcaleNieWolny commented May 10, 2026

Summary

Switches /private/config/builder to the backend-standard Hono bootstrap and adds structured request-id logging, addressing review feedback that the endpoint diverged from the conventions used by other backend routes.

  • Replace new Hono<MiddlewareKeyVariables>() with createHono('', version) from utils/hono.ts (still mounts useCors).
  • In the GET / handler, read c.get('requestId') and emit cloudlog({ requestId, context: 'config_builder', enabled, ... }) for both the disabled (missing env vars) and enabled responses.
  • Logs scopeCount rather than the raw scopes/secret payload to keep logs small and avoid persisting OAuth values.

No behavior change: the response shape and status codes are identical; tests in tests/config-builder.unit.test.ts continue to pass.

Test plan

  • bunx vitest run tests/config-builder.unit.test.ts — 8/8 pass
  • bunx eslint supabase/functions/_backend/private/config_builder.ts — clean
  • Manual smoke: hit /private/config/builder with and without GOOGLE_OAUTH_CLIENT_ID/GOOGLE_OAUTH_CLIENT_SECRET; verify a requestId field appears in logs for each response

Summary by CodeRabbit

  • Improvements
    • Enhanced diagnostic logging when required OAuth credentials are missing.
    • Improved visibility into OAuth scope configuration returned by the API.
    • Simplified metric amount formatting for organization credits, producing cleaner displayed values.

Review Change Stack

…nfig_builder

Switch /private/config/builder to the backend-standard createHono factory and
add cloudlog calls with c.get('requestId') for both the disabled and enabled
branches, matching the convention in other backend endpoints.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 10, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: eccf71c4-1f4b-489d-ad46-a58802ea26fa

📥 Commits

Reviewing files that changed from the base of the PR and between e9f01d8 and 1f6973d.

📒 Files selected for processing (2)
  • src/pages/settings/organization/Credits.vue
  • supabase/functions/_backend/private/config_builder.ts
💤 Files with no reviewable changes (1)
  • src/pages/settings/organization/Credits.vue
🚧 Files skipped from review as they are similar to previous changes (1)
  • supabase/functions/_backend/private/config_builder.ts

📝 Walkthrough

Walkthrough

Refactors Hono app creation to use a shared factory, adds requestId and OAuth-credential logging to the config builder GET handler, extracts and logs parsed OAuth scopes before returning them, and removes an unused intermediate formatting variable in Credits.vue.

Changes

Config Builder Handler Enhancement

Layer / File(s) Summary
Imports and Utility References
supabase/functions/_backend/private/config_builder.ts
Module imports updated to use createHono and useCors from local Hono utilities; logging/env/version imports adjusted.
App Initialization
supabase/functions/_backend/private/config_builder.ts
Exported Hono app instance initialized via createHono('', version) instead of direct new Hono<MiddlewareKeyVariables>(); CORS mounted on /.
Handler Credential Logging
supabase/functions/_backend/private/config_builder.ts
GET / reads requestId, checks for Google OAuth client ID/secret, logs disabled state with request context when missing, and returns { enabled: false }.
Scope Computation and Logging
supabase/functions/_backend/private/config_builder.ts
Scope parsing extracted to local scopes via parseScopes, scopeCount logged, and scopes returned from the variable rather than inlining the call.

Credits.vue Formatting Tweak

Layer / File(s) Summary
Formatting Helper
src/pages/settings/organization/Credits.vue
formatMetricAmount removes an unused intermediate Intl.NumberFormat result and formats returned strings inline within switch cases.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • Cap-go/capgo#2051: Adds the config builder endpoint and initial wiring; touches the same supabase/functions/_backend/private/config_builder.ts handler.
  • Cap-go/capgo#2085: Modifies overlapping areas including Credits.vue formatting and the config builder handler.

Poem

🐰
I hopped through imports, tidy and spry,
turned Hono to a factory, gave logs a try.
Scopes counted neat, request IDs in tow,
a tiny Vue tweak — formats now flow.
🥕✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main refactoring: switching to createHono and adding request-id logging in the config_builder endpoint.
Description check ✅ Passed The PR description covers the summary, test plan, and includes checkboxes, though the manual smoke test checkbox is unchecked indicating it's pending completion.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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/config-builder-createhono-logging

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

@codspeed-hq
Copy link
Copy Markdown
Contributor

codspeed-hq Bot commented May 10, 2026

Merging this PR will not alter performance

✅ 43 untouched benchmarks
⏩ 2 skipped benchmarks1


Comparing fix/config-builder-createhono-logging (1f6973d) with main (5e19137)2

Open in CodSpeed

Footnotes

  1. 2 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

  2. No successful run was found on main (cb23097) during the generation of this report, so 5e19137 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

…eatehono-logging

# Conflicts:
#	supabase/functions/_backend/private/config_builder.ts
@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@sonarqubecloud
Copy link
Copy Markdown

@riderx riderx merged commit 9012c97 into main May 10, 2026
39 checks passed
@riderx riderx deleted the fix/config-builder-createhono-logging branch May 10, 2026 18:18
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