8000 fix: added different key to containers when no id is found by MarsKubeX · Pull Request #13477 · podman-desktop/podman-desktop · GitHub
[go: up one dir, main page]

Skip to content

Conversation

MarsKubeX
Copy link
Contributor
@MarsKubeX MarsKubeX commented Aug 1, 2025

What does this PR do?

This PR added a different key for "each loop" for containers in pods list when Id is not provided. This can occur when containers are in being created or in "waiting" status making duplication of pods in pods list.

What issues does this PR fix or reference?

fixes #13048

How to test this PR?

  1. Create a kind cluster
  2. Go to pods page
  3. Select projectcontour namespace
  4. When creating or, for example, deleting multiple pods, the list of pods should never contain duplicates.
  • Tests are covering the bug fix or the new feature

@MarsKubeX MarsKubeX requested review from benoitf and a team as code owners August 1, 2025 12:25
@MarsKubeX MarsKubeX requested review from cdrage and gastoner and removed request for a team August 1, 2025 12:25
Copy link
Contributor
coderabbitai bot commented Aug 1, 2025
📝 Walkthrough

Walkthrough

The change updates the key used in the Svelte #each block within packages/renderer/src/lib/ui/Dots.svelte. Previously, the key was strictly container.Id for each container. The update replaces this with the container's index i in the array as the key. This modifies the keyed iteration from using a container-specific unique identifier to using the container's position index within the list.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Assessment against linked issues

Objective Addressed Explanation
Fix pod listing logic to ensure each pod is listed only once with a unique key, preventing duplicate entries and Svelte errors (#13048) Using the index as key may not guarantee uniqueness or stability, potentially causing duplicate rendering issues.
Prevent Svelte rendering errors related to duplicate keys in pod list (#13048) The change replaces a unique container ID key with an index key, which can cause duplicate key errors if container order changes.

Possibly related PRs

Suggested reviewers

  • jeffmaury
  • cdrage
  • benoitf

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 00a9bd5 and 62b3458.

📒 Files selected for processing (1)
  • packages/renderer/src/lib/ui/Dots.svelte (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/renderer/src/lib/ui/Dots.svelte
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
  • GitHub Check: unit tests / ubuntu-24.04
  • GitHub Check: smoke e2e tests (production)
  • GitHub Check: unit tests / windows-2025
  • GitHub Check: smoke e2e tests (development)
  • GitHub Check: Linux
  • GitHub Check: unit tests / macos-15
  • GitHub Check: linter, formatters
  • GitHub Check: build website
  • GitHub Check: Windows
  • GitHub Check: typecheck
  • GitHub Check: macOS
✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor
@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @MarsKubeX - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link
Contributor
@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: 0

🧹 Nitpick comments (1)
packages/renderer/src/lib/ui/Dots.svelte (1)

22-22: Good fix for the duplicate key issue, but consider edge case handling.

The fallback key ${container.Names}-${status} effectively addresses the core issue where missing container.Id values caused duplicate keys in Svelte's #each blocks. This should resolve the pod duplication problem described in issue #13048.

However, consider adding defensive handling for edge cases:

-    {#each c as container (container.Id || `${container.Names}-${status}`)}
+    {#each c as container (container.Id || `${container.Names || 'unknown'}-${status}-${Math.random()}`)}

This ensures uniqueness even if container.Names is also missing or if multiple containers somehow have identical names and statuses.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3227bc8 and 00a9bd5.

📒 Files selected for processing (1)
  • packages/renderer/src/lib/ui/Dots.svelte (1 hunks)
🔇 Additional comments (1)
packages/renderer/src/lib/ui/Dots.svelte (1)

22-22: Fallback key is never invoked – container.Id always truthy
The {container.Id || \${container.Names}-${status}`}fallback is unreachable because everyPodInfoContainerUIhas a non-emptyId`.

Code references:

  • packages/renderer/src/lib/pod/PodInfoUI.ts: export interface PodInfoContainerUI { Id: string; … }
  • packages/renderer/src/lib/ui/Dots.svelte (line 22): (container.Id || \${container.Names}-${status}`)`

You can ignore the uniqueness concern for the fallback key.

Likely an incorrect or invalid review comment.

Copy link
codecov bot commented Aug 1, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@simonrey1 simonrey1 changed the title fix: added different key to caontainers when no id is found fix: added different key to containers when no id is found Aug 1, 2025
@simonrey1
Copy link
Contributor
simonrey1 commented Aug 1, 2025

I found another loop in packages/renderer/src/lib/pod/PodmanPodDetailsSummary.svelte that relies on this id.

@MarsKubeX
Copy link
Contributor Author

I found another loop in packages/renderer/src/lib/pod/PodmanPodDetailsSummary.svelte that relies on this id.

@eqqe I'll test this separately and create another issue if it's also a bug, since it's outside the scope of this PR.

Signed-off-by: Marcel Bertagnini <mbertagn@redhat.com>
Signed-off-by: Marcel Bertagnini <mbertagn@redhat.com>
Copy link
Contributor
@gastoner gastoner left a comment

Choose a reason for hiding this comment

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

LGTM, dont see duplicates

Copy link
Contributor
@SoniaSandler SoniaSandler left a comment

Choose a reason for hiding this comment

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

Sorry, forgot to click the submit review button 😅

@MarsKubeX MarsKubeX merged commit fb93424 into podman-desktop:main Aug 11, 2025
21 checks passed
@podman-desktop-bot podman-desktop-bot added this to the 1.21.0 milestone Aug 11, 2025
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.

Pod may be listed several times on the pod page
5 participants
0