Skip to content

Fix: solve duplicate key error in simulation #2562

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

miguelro20
Copy link

Fixes #2554

Description

The fix was made to prevent an error that happened in simulation page because of duplicate keys.

Changes

Changed the key used inside the table from start-time to unique key. The unique key was already included in the code, the fix was to add it in the simulation object.

Copy link

vercel bot commented May 23, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
policyengine-app ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 31, 2025 7:48am

Copy link
Collaborator

@anth-volk anth-volk left a comment

Choose a reason for hiding this comment

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

Thanks for your changes @miguelro20. Had a question for you before proceeding.

@@ -119,7 +124,7 @@ export default function SimulationsPage() {
</p>
</PageHeader>
<Section>
<Table dataSource={data} columns={columns} rowKey="start_time" />
<Table dataSource={data} columns={columns} rowKey="rowKey" />
Copy link
Collaborator

@anth-volk anth-volk May 30, 2025

Choose a reason for hiding this comment

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

issue, blocking: Per Ant Design's docs here, the rowKey prop defaults to a given row's key value; is the fix not as simple as removing the original rowKey="start_time" designation?

@github-project-automation github-project-automation bot moved this from Todo to PR: Review Requested in policyengine-app May 30, 2025
@miguelro20
Copy link
Author

I have made a change, now each simulation object holds a key inside of it.
Replying to this comment:
issue, blocking: Per Ant Design's docs here, the rowKey prop defaults to a given row's key value; is the fix not as simple as removing the original rowKey="start_time" designation?

I did try that solution, but what happened was that the Table object can take a unique key value from within the rendered object, and our simulation object did not have that value. In this follow up, I renamed the value from rowKey to key inside the simulation object, this way the Table takes the value with the key name without needing to specify it on the

object and no errors show up on the page when running the app.

Copy link
Collaborator

@anth-volk anth-volk left a comment

Choose a reason for hiding this comment

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

Your explanation sounds good to me. LGTM pending test passage.

@anth-volk
Copy link
Collaborator

Ah, this actually fails CI. Could you run make format and push the result?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: PR: Review Requested
Development

Successfully merging this pull request may close these issues.

React duplicate key error in simulation queue page
2 participants