Skip to content

Attempt to handle UBT files uploaded to PnP spots better #3506

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: develop
Choose a base branch
from

Conversation

CarsonF
Copy link
Member

@CarsonF CarsonF commented Jun 19, 2025

Render a specific error & don't log this as a problem for devs.

CarsonF added 2 commits June 19, 2025 08:33
Render a specific error & don't log this as a problem for devs.
Copy link

coderabbitai bot commented Jun 19, 2025

📝 Walkthrough

Walkthrough

The changes introduce enhanced type safety and error handling for file processing across several components. The Pnp class and related extractors now consistently use the Downloadable<FileVersion> type instead of a generic Downloadable<unknown>. The Pnp class constructor and methods are updated to accept an optional filename for improved error diagnostics, and a new NotPnPFile exception is added to distinguish budget files from PnP files. Error logging is refined to avoid logging known file-type errors.

Changes

Files/Areas Change Summary
src/components/pnp/pnp.ts Pnp class constructor and methods updated to accept optional filename; new NotPnPFile exception; improved error handling and type safety for sheet access.
src/components/product-progress/step-progress-extractor.service.ts
src/components/product/product.extractor.ts
src/components/progress-summary/progress-summary.extractor.ts
Extractor method parameter types changed from Downloadable<unknown> to Downloadable<FileVersion>; imports updated.
src/components/product/pnp-product-sync.service.ts Error handling in parse method updated to suppress logging for NotPnPFile exceptions.
src/repl.ts loadPnp function updated to pass the base filename to Pnp.fromBuffer for better file context.

📜 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 6cdf774 and e1419e0.

📒 Files selected for processing (6)
  • src/components/pnp/pnp.ts (1 hunks)
  • src/components/product-progress/step-progress-extractor.service.ts (2 hunks)
  • src/components/product/pnp-product-sync.service.ts (2 hunks)
  • src/components/product/product.extractor.ts (2 hunks)
  • src/components/progress-summary/progress-summary.extractor.ts (2 hunks)
  • src/repl.ts (2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (5)
src/components/product/pnp-product-sync.service.ts (2)
src/components/pnp/pnp.ts (1)
  • NotPnPFile (54-54)
src/components/engagement/language-engagement.resolver.ts (1)
  • pnp (39-44)
src/repl.ts (1)
src/components/pnp/pnp.ts (1)
  • Pnp (9-52)
src/components/product-progress/step-progress-extractor.service.ts (1)
src/components/file/dto/file.dto.ts (1)
  • Downloadable (192-195)
src/components/progress-summary/progress-summary.extractor.ts (1)
src/components/file/dto/file.dto.ts (1)
  • Downloadable (192-195)
src/components/product/product.extractor.ts (1)
src/components/file/dto/file.dto.ts (1)
  • Downloadable (192-195)
⏰ Context from checks skipped due to timeout of 90000ms (12)
  • GitHub Check: lint
  • GitHub Check: E2E Tests (neo4j 4/6)
  • GitHub Check: E2E Tests (neo4j 6/6)
  • GitHub Check: E2E Tests (neo4j 3/6)
  • GitHub Check: E2E Tests (neo4j 5/6)
  • GitHub Check: E2E Tests (neo4j 2/6)
  • GitHub Check: E2E Tests (neo4j 1/6)
  • GitHub Check: Unit
  • GitHub Check: Generate (head)
  • GitHub Check: Clean
  • GitHub Check: Generate (base)
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (17)
src/components/product/pnp-product-sync.service.ts (2)

10-10: LGTM: Import added for new exception type.

The NotPnPFile import supports the enhanced error handling logic introduced below.


71-76: Excellent error handling improvement.

This conditional logging perfectly addresses the PR objective by preventing UBT file upload attempts from cluttering developer logs while still logging genuine extraction errors. The logic correctly excludes only NotPnPFile exceptions from logging while maintaining the same return behavior for all error cases.

src/components/progress-summary/progress-summary.extractor.ts (2)

11-11: LGTM: Type import added for enhanced type safety.

Adding FileVersion import supports the improved type annotation in the extract method.


22-22: Excellent type safety improvement.

Changing from Downloadable<unknown> to Downloadable<FileVersion> provides better type safety and consistency with similar extractors. The FileVersion type enables access to filename metadata which supports the enhanced error handling introduced in the Pnp class.

src/repl.ts (2)

9-9: LGTM: Import added for filename extraction.

The basename import supports extracting the filename from the filepath for enhanced error detection.


50-51: Good enhancement for REPL debugging.

Passing basename(filepath) to Pnp.fromBuffer provides filename context that enables the enhanced error handling logic in the Pnp class, particularly for detecting UBT files based on filename patterns. This improves the debugging experience in the REPL environment.

src/components/product-progress/step-progress-extractor.service.ts (2)

6-6: LGTM: Type import added for consistency.

Adding FileVersion import aligns with the type safety improvements across extractor services.


48-48: Good type safety improvement.

Updating the parameter type from Downloadable<unknown> to Downloadable<FileVersion> improves type safety and provides consistent typing across all extractor services. This enables access to filename metadata that supports enhanced error handling.

src/components/product/product.extractor.ts (2)

8-8: LGTM: Import completes coordinated type safety effort.

Adding FileVersion import aligns with the consistent type improvements across all extractor services.


34-34: Excellent completion of coordinated type safety improvements.

This change from Downloadable<unknown> to Downloadable<FileVersion> completes the consistent type safety improvements across all extractor services (ProductExtractor, StepProgressExtractor, and ProgressSummaryExtractor). The enhanced typing provides access to filename metadata that supports the improved error handling for UBT file detection.

src/components/pnp/pnp.ts (7)

1-3: Enhanced imports for type safety and error handling.

The new imports support the enhanced type safety (FileVersion, Sheet) and improved error handling (InputException, NotFoundException) introduced in this PR.


10-10: Constructor enhancement for filename context.

Adding the optional fileName parameter enables better error diagnostics, which is effectively utilized in the error handling logic below.


16-16: Improved type safety with specific FileVersion type.

The parameter type change from Downloadable<unknown> to Downloadable<FileVersion> provides better type safety and the filename is properly passed through for error handling.

Also applies to: 19-19


24-24: Filename propagation through processing chain.

The name parameter is correctly propagated from the static method to the constructor, enabling filename-based error detection.

Also applies to: 28-28


32-32: Refactored getters with centralized error handling.

The getters now use the new sheet<TSheet> method which centralizes error handling logic. This is a good refactoring that reduces code duplication.

Also applies to: 36-37


39-51: Well-implemented UBT file detection logic.

The error handling logic effectively detects UBT files using a word boundary regex pattern and provides a clear, user-friendly error message. The exception chaining preserves the original error context.

Key strengths:

  • Safe optional chaining with this.fileName?.match()
  • Appropriate regex pattern /\bUBT\b/ using word boundaries
  • Clear error message distinguishing budget files from PnP files
  • Proper exception chaining with the original exception as cause

54-54: New exception class for specific error case.

The NotPnPFile exception class properly extends InputException and provides a specific error type for this use case, enabling better error handling downstream.

✨ Finishing Touches
  • 📝 Generate Docstrings

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.
    • @coderabbitai modularize this function.
  • 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.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

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

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

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 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.

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