Skip to content

refactor(tagging-issues): replace RPC call with REST endpoint#1023

Open
bubelov wants to merge 2 commits into
mainfrom
no-rpc
Open

refactor(tagging-issues): replace RPC call with REST endpoint#1023
bubelov wants to merge 2 commits into
mainfrom
no-rpc

Conversation

@bubelov
Copy link
Copy Markdown
Collaborator

@bubelov bubelov commented May 26, 2026

This PR is aimed to be as non invasive as possible, broader refactoring, such as renaming RpcIssue to something more appropriate will follow.

This new REST endpoint is supposed to be an exact copy of the corresponding RPC endpoint:

https://github.com/teambtcmap/btcmap-api/blob/master/docs/rest/v4/place-issues.md

Summary by CodeRabbit

  • Refactor
    • Improved how element issues are retrieved and processed, increasing reliability of issue loading.
  • Bug Fixes
    • Enhanced error handling so failed loads surface clearer error states to the page.
  • User Impact
    • No visual changes; issue lists and table rendering behave the same but load more reliably and fail more transparently when problems occur.

Review Change Stack

@qodo-code-review
Copy link
Copy Markdown
Contributor

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@netlify
Copy link
Copy Markdown

netlify Bot commented May 26, 2026

Deploy Preview for btcmap ready!

Name Link
🔨 Latest commit 9004d0d
🔍 Latest deploy log https://app.netlify.com/projects/btcmap/deploys/6a152a786b16fa0008a246d6
😎 Deploy Preview https://deploy-preview-1023--btcmap.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 40 (🔴 down 31 from production)
Accessibility: 97 (no change from production)
Best Practices: 92 (🔴 down 8 from production)
SEO: 96 (no change from production)
PWA: 90 (no change from production)
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

@bubelov bubelov requested a review from escapedcat May 26, 2026 05:03
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 26, 2026

📝 Walkthrough

Walkthrough

The tagging-issues loader switches from a JSON-RPC POST to a REST GET (/v4/place-issues), checks HTTP status via response.ok, returns the parsed JSON under result, and the Svelte page reads data.result.requested_issues.

Changes

API Migration from RPC to REST

Layer / File(s) Summary
REST endpoint migration in tagging-issues loader
src/routes/tagging-issues/+page.server.ts, src/routes/tagging-issues/+page.svelte
The loader replaces the RPC get_element_issues call with a REST fetch to /v4/place-issues, updates error handling to check response.ok and return HTTP error messages, changes the returned shape from { rpcResult: ... } to { result: ... }, and updates the Svelte page to read requested_issues from data.result.

🎯 2 (Simple) | ⏱️ ~8 minutes

Suggested labels: Review effort 2/5

Suggested reviewers:

  • dadofsambonzuki

"🐰 A hop from RPC to REST,
Fetch returns JSON, no more quest,
HTTP checks now keep the pace,
Result lands in the right place,
Issues ready for the UI's nest."

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is incomplete relative to the template; it lacks required sections: issue reference, detailed change description, screenshots, and additional context. Add the missing sections: clearly reference the related issue, provide a detailed description of all changes made, include screenshots if applicable, and explain any additional context or considerations.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: replacing an RPC call with a REST endpoint in the tagging-issues route.
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.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch no-rpc

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint skipped: no ESLint configuration detected in root package.json. To enable, add eslint to devDependencies.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/routes/tagging-issues/`+page.server.ts:
- Around line 20-22: The loader currently returns `{ result: data }` which
breaks the page expecting `data.rpcResult.requested_issues`; update the return
value in src/routes/tagging-issues/+page.server.ts so that the payload includes
`rpcResult` (e.g., return `{ rpcResult: data }` or include both `result` and
`rpcResult`) to preserve the existing contract used by +page.svelte.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7af56a95-52a1-4dd8-808b-40dd074ceaa4

📥 Commits

Reviewing files that changed from the base of the PR and between 1400fb7 and 28d42b3.

📒 Files selected for processing (1)
  • src/routes/tagging-issues/+page.server.ts

Comment on lines 20 to 22
return {
rpcResult: data.result,
result: data,
};
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Keep the loader success payload backward-compatible with the page contract.

Line 21 returns { result: data }, but src/routes/tagging-issues/+page.svelte still reads data.rpcResult.requested_issues (Line 10 there). This will break successful page loads when rpcResult is undefined.

Suggested fix
 		return {
-			result: data,
+			rpcResult: data,
+			result: data,
 		};
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
return {
rpcResult: data.result,
result: data,
};
return {
rpcResult: data,
result: data,
};
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/routes/tagging-issues/`+page.server.ts around lines 20 - 22, The loader
currently returns `{ result: data }` which breaks the page expecting
`data.rpcResult.requested_issues`; update the return value in
src/routes/tagging-issues/+page.server.ts so that the payload includes
`rpcResult` (e.g., return `{ rpcResult: data }` or include both `result` and
`rpcResult`) to preserve the existing contract used by +page.svelte.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/routes/tagging-issues/`+page.svelte:
- Line 10: The render assumes data.result exists and will crash when the loader
returns an HTTP-error without result; update the initialization of issues (the
let issues: RpcIssue[] assignment) to defensively read
data.result.requested_issues and fall back to an empty array (or other safe
default) when data or data.result is missing (e.g., use a null-safe access on
data and result and a default value for requested_issues) so the component can
render safely even on error responses.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c4555479-3ae1-4674-9512-be20ddbafef9

📥 Commits

Reviewing files that changed from the base of the PR and between 28d42b3 and 9004d0d.

📒 Files selected for processing (1)
  • src/routes/tagging-issues/+page.svelte


export let data;
let issues: RpcIssue[] = data.rpcResult.requested_issues;
let issues: RpcIssue[] = data.result.requested_issues;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Guard against missing result to avoid runtime crashes.

Line 10 assumes data.result always exists, but the loader’s HTTP-error branch returns no result, so this can throw during render.

Suggested fix
-let issues: RpcIssue[] = data.result.requested_issues;
+let issues: RpcIssue[] = data.result?.requested_issues ?? [];
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
let issues: RpcIssue[] = data.result.requested_issues;
let issues: RpcIssue[] = data.result?.requested_issues ?? [];
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/routes/tagging-issues/`+page.svelte at line 10, The render assumes
data.result exists and will crash when the loader returns an HTTP-error without
result; update the initialization of issues (the let issues: RpcIssue[]
assignment) to defensively read data.result.requested_issues and fall back to an
empty array (or other safe default) when data or data.result is missing (e.g.,
use a null-safe access on data and result and a default value for
requested_issues) so the component can render safely even on error responses.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors the /tagging-issues route to fetch element/place tagging issues via the btcmap-api v4 REST endpoint instead of the legacy JSON-RPC endpoint, aiming to keep behavior identical while improving error surfacing.

Changes:

  • Replaced the JSON-RPC POST call with a GET request to /v4/place-issues in the server load.
  • Updated the page to read issues from the new data.result shape.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/routes/tagging-issues/+page.svelte Switched client-side data access from rpcResult to result for issues.
src/routes/tagging-issues/+page.server.ts Replaced RPC fetch with REST fetch and adjusted returned payload shape.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +11 to 22
if (!response.ok) {
return {
error: errorMessage + errorDetails,
error: `HTTP Error: ${response.status}`,
rpcResult: null,
};
}

const data = await response.json();

return {
rpcResult: data.result,
result: data,
};
Comment on lines 9 to 11
export let data;
let issues: RpcIssue[] = data.rpcResult.requested_issues;
let issues: RpcIssue[] = data.result.requested_issues;
</script>
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