Skip to content

fix(BA-1998): Resolve VFolder permissions field in Compute session node #5322

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

Merged
merged 4 commits into from
Aug 6, 2025

Conversation

fregataa
Copy link
Member

@fregataa fregataa commented Jul 28, 2025

resolves #5321 (BA-1998)

Checklist: (if applicable)

  • Milestone metadata specifying the target backport version
  • Mention to the original issue
  • Installer updates including:
    • Fixtures for db schema changes
    • New mandatory config options
  • Update of end-to-end CLI integration tests in ai.backend.test
  • API server-client counterparts (e.g., manager API -> client SDK)
  • Test case(s) to:
    • Demonstrate the difference of before/after
    • Demonstrate the flow of abstract/conceptual models with a concrete implementation
  • Documentation
    • Contents in the docs directory
    • docstrings in public interfaces and type annotations

@fregataa fregataa added this to the 25Q2 milestone Jul 28, 2025
@fregataa fregataa self-assigned this Jul 28, 2025
@Copilot Copilot AI review requested due to automatic review settings July 28, 2025 04:33
@github-actions github-actions bot added size:XS ~10 LoC comp:manager Related to Manager component labels Jul 28, 2025
Copy link
Contributor

@Copilot 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

This pull request adds a null check to the VFolder node resolver to prevent potential null reference errors when a VFolder row is not found in the database.

  • Adds explicit type casting and null validation for the database query result
  • Returns None early when no VFolder row is found instead of proceeding with potentially null data

@@ -258,6 +259,9 @@ async def get_node(
query = query.where(sa.and_(cond, VFolderRow.id == uuid.UUID(vfolder_row_id)))
async with graph_ctx.db.begin_readonly_session(db_conn) as db_session:
vfolder_row = await db_session.scalar(query)
vfolder_row = cast(Optional[VFolderRow], vfolder_row)
Copy link
Preview

Copilot AI Jul 28, 2025

Choose a reason for hiding this comment

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

The cast to Optional[VFolderRow] is unnecessary since the database query already returns Optional[VFolderRow]. This cast doesn't provide additional type safety and adds redundant code.

Suggested change
vfolder_row = cast(Optional[VFolderRow], vfolder_row)

Copilot uses AI. Check for mistakes.

@@ -258,6 +259,9 @@ async def get_node(
query = query.where(sa.and_(cond, VFolderRow.id == uuid.UUID(vfolder_row_id)))
async with graph_ctx.db.begin_readonly_session(db_conn) as db_session:
vfolder_row = await db_session.scalar(query)
vfolder_row = cast(Optional[VFolderRow], vfolder_row)
if vfolder_row is None:
return None
Copy link
Preview

Copilot AI Jul 28, 2025

Choose a reason for hiding this comment

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

The indentation level suggests this null check is only executed within the database session context, but it should be performed after the session regardless of the query path. Consider moving this check outside the conditional block to ensure it covers all code paths.

Copilot uses AI. Check for mistakes.

@fregataa fregataa changed the title fix(BA-1998): Do null check in VFolder node resolver fix(BA-1998): Resolve VFolder permissions field in Compute session node Jul 28, 2025
@fregataa fregataa requested a review from yomybaby July 28, 2025 04:34
@github-actions github-actions bot added size:M 30~100 LoC and removed size:XS ~10 LoC labels Jul 28, 2025
@fregataa fregataa requested a review from agatha197 August 5, 2025 10:27
Copy link
Contributor

@agatha197 agatha197 left a comment

Choose a reason for hiding this comment

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

It works! LGTM

@fregataa fregataa enabled auto-merge August 6, 2025 08:42
@fregataa fregataa added this pull request to the merge queue Aug 6, 2025
Merged via the queue into main with commit 2be2e79 Aug 6, 2025
29 checks passed
@fregataa fregataa deleted the fix/vfolder-node-null-check branch August 6, 2025 08:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:manager Related to Manager component size:M 30~100 LoC
Projects
None yet
Development

Successfully merging this pull request may close these issues.

VFolder permission fields in other nodes not resolved
2 participants