Skip to content

Error fetching community members#20

Merged
tekrajchhetri merged 1 commit intomasterfrom
dev
Aug 15, 2025
Merged

Error fetching community members#20
tekrajchhetri merged 1 commit intomasterfrom
dev

Conversation

@tekrajchhetri
Copy link
Collaborator

472-4aa9a1a99457b1f9.js:1 Error fetching community members: SyntaxError: Unexpected end of JSON input
at JSON.parse ()
at page-e7c2a7a72c45c5ef.js:1:16541
at Array.map ()
at fetchCommunityMembers (page-e7c2a7a72c45c5ef.js:1:16529)
at async page-e7c2a7a72c45c5ef.js:1:17265



@tekrajchhetri tekrajchhetri merged commit 1eedef3 into master Aug 15, 2025
1 check failed
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Summary of Changes

Hello @tekrajchhetri, 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 fetching community members failed due to an Unexpected end of JSON input error. It resolves this by enhancing the JSON parsing logic to gracefully handle malformed data and adds comprehensive logging to assist in diagnosing future data fetching problems.

Highlights

  • Data Parsing Robustness: Enhanced the fetchCommunityMembers function in ui/lib/data.ts to include a try-catch block around JSON.parse calls, preventing crashes from malformed JSON lines and providing specific error messages for problematic data.
  • Debugging Improvements: Integrated additional logging within fetchCommunityMembers to output details such as the raw response text length, a preview of the response, the total number of lines, and the content of the first line, which will be invaluable for debugging data integrity issues.
Using Gemini Code Assist

The 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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request attempts to fix an error when fetching community members by adding more robust JSONL parsing. However, the root cause of the issue is that the client is attempting to parse a single JSON object response as JSONL. The API already provides the transformed data, so the client-side transformation is also redundant. My review includes a critical comment with a suggested fix that correctly parses the API response and simplifies the function, removing the redundant logic.

Comment on lines +18 to +34
const text = await response.text();
console.log('Response text length:', text.length);
console.log('Response text preview:', text.substring(0, 200));

const lines = text.trim().split('\n');
console.log('Number of lines:', lines.length);
console.log('First line:', lines[0]);

// Parse JSONL data
const kgData = lines.map(line => JSON.parse(line));
const kgData = lines.map((line, index) => {
try {
return JSON.parse(line);
} catch (error) {
console.error(`Error parsing line ${index}:`, line, error);
throw error;
}
});

Choose a reason for hiding this comment

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

critical

This change attempts to fix a JSON parsing error by adding more detailed error logging. However, the root cause of the error is a misunderstanding of the API response format.

The API endpoint /api/data returns a single JSON object, not a JSONL stream. Therefore, trying to parse it line-by-line will fail, leading to the SyntaxError.

Additionally, the API already performs the data transformation from raw knowledge graph entries to community members, including generating categories. The client-side transformation logic that follows this block is redundant and inefficient.

The correct approach is to parse the entire response as a single JSON object and use the data directly. This also has the benefit of removing the temporary console.log statements.

I suggest replacing this block with code that parses the JSON and returns the data. This will make the subsequent transformation code in this function redundant, and it should be removed.

Suggested change
const text = await response.text();
console.log('Response text length:', text.length);
console.log('Response text preview:', text.substring(0, 200));
const lines = text.trim().split('\n');
console.log('Number of lines:', lines.length);
console.log('First line:', lines[0]);
// Parse JSONL data
const kgData = lines.map(line => JSON.parse(line));
const kgData = lines.map((line, index) => {
try {
return JSON.parse(line);
} catch (error) {
console.error(`Error parsing line ${index}:`, line, error);
throw error;
}
});
const data = await response.json();
return { members: data.materials, categories: data.categories };

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.

1 participant