Skip to content

feat: add skipped records report with reasons - #323

Open
dominatos wants to merge 2 commits into
dickwolff:mainfrom
dominatos:feature/skipped-records-report
Open

feat: add skipped records report with reasons#323
dominatos wants to merge 2 commits into
dickwolff:mainfrom
dominatos:feature/skipped-records-report

Conversation

@dominatos

Copy link
Copy Markdown

Summary

When converting a CSV file, some records may be skipped for various reasons. This PR introduces a skipped records report to give users visibility into what was skipped and why.

Changes

  • Adds SkippedRecord model with line number, raw CSV line, and reason
  • Adds addSkippedRecord() and getSkippedRecords() methods to AbstractConverter
  • Updates all skip/continue paths in converters to call addSkippedRecord()
  • After conversion, if any records were skipped, writes a skipped-records-<converter>-<timestamp>.csv file to the output folder
  • Controlled by env var GHOSTFOLIO_SHOW_SKIPPED (default: true)

Reasons a record may be skipped

  • The record type is intentionally ignored (e.g. deposits, withdrawals)
  • No matching security symbol could be found
  • The record could not be matched to a valid transaction type
  • An error occurred looking up the security

Testing

Converters updated to report skipped records with descriptive reasons. Output CSV is only written when at least one record was skipped.

@dominatos
dominatos requested a review from dickwolff as a code owner April 2, 2026 16:37
@coderabbitai

coderabbitai Bot commented Apr 2, 2026

Copy link
Copy Markdown

Walkthrough

Adds skipped-record tracking and reporting and updates configuration: introduces a new SkippedRecord interface; AbstractConverter now accumulates skips and exposes addSkippedRecord and getSkippedRecords; degiroConverterV2 records skipped rows with line numbers and raw lines; createAndRunConverter writes a skipped-records CSV when GHOSTFOLIO_SHOW_SKIPPED is enabled. Separately, .env.sample was rewritten to remove INPUT_FILE, add E2G_INPUT_FOLDER/E2G_OUTPUT_FOLDER, and standardize Ghostfolio, logging, cache, and polling environment flags.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • Add Invest Engine #248 — touches the same converter core files (src/converter.ts, src/converters/abstractconverter.ts), indicating overlapping changes to converter routing and skipped-record/reporting logic.
  • Add Disnat converter #270 — affects converters that extend AbstractConverter (e.g., Disnat), so it may need adjustments to use the new addSkippedRecord/getSkippedRecords API.
🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description provides a comprehensive summary of changes, specific file modifications, the feature's purpose, and testing notes. However, it deviates from the required template structure. Restructure the description to follow the provided template with sections for Added, Fixes, Checklist, and Related issue. Ensure all required checklist items are addressed.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main feature being added: a skipped records report that includes reasons why records are skipped.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.env.sample:
- Around line 1-39: Add the missing INPUT_FILE variable back into .env.sample
because src/manual.ts still reads process.env.INPUT_FILE and passes it into
createAndRunConverter(); update .env.sample to include a descriptive line like
"INPUT_FILE=/path/to/input-file" (or an empty placeholder) and a short comment
explaining it's used by the manual entrypoint so developers don't get an
undefined path at runtime; leave this in place until src/manual.ts is changed to
stop using process.env.INPUT_FILE or createAndRunConverter() is made robust to
undefined inputs.

In `@src/converter.ts`:
- Around line 100-106: The CSV generation in converter.ts currently only quotes
fields (escapedRaw/escapedReason) but doesn't neutralize formula-injection risk
from untrusted skipped.rawLine and skipped.reason; update the logic where
escapedRaw and escapedReason are created (the block building csvLines from
skippedRecords) to first escape internal quotes, then if the resulting cell
begins with any of = + - @ prefix a single quote (') or a safe character to
neutralize spreadsheet formulas, and finally wrap in quotes as before so both
rawLine and reason are sanitized before being written to csvLines.

In `@src/converters/abstractconverter.ts`:
- Around line 12-13: The skippedRecords accumulator (private skippedRecords:
SkippedRecord[]) is never reset between runs, so getSkippedRecords() returns
stale entries; fix by clearing this.skippedRecords = [] at the start of the
conversion entry point(s) (e.g., in AbstractConverter.convert / the method that
begins a conversion run) so each run starts with an empty array; also ensure any
other conversion entry helper referenced around the area noted (lines ~118-124)
similarly resets skippedRecords before processing.

In `@src/converters/degiroConverterV2.ts`:
- Around line 26-27: The current use of rawLines = input.split(...) and deriving
rawLine/lineNumber from idx is incorrect when CSV fields can contain embedded
newlines; instead, modify the parsing in degiroConverterV2 so each parsed record
carries its original source slice or start/end index (do not rely on rawLines or
input.split). Update the parser (or wrap the CSV parse loop) to record for each
output row a rawText or sourceStart/sourceEnd and then use that stored
rawText/source indices for skipped-record reporting (replace uses of rawLine,
lineNumber, and idx at the current reporting sites including the later
occurrences around the logic referenced at 76-78). Ensure downstream code that
reports skipped records reads the stored per-record source info rather than
recomputing via input.split.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c7ec475b-4be4-4cce-bbb2-96097610f2b7

📥 Commits

Reviewing files that changed from the base of the PR and between 9e35bd6 and d727fae.

📒 Files selected for processing (5)
  • .env.sample
  • src/converter.ts
  • src/converters/abstractconverter.ts
  • src/converters/degiroConverterV2.ts
  • src/models/skippedRecord.ts

Comment thread .env.sample
Comment thread src/converter.ts
Comment thread src/converters/abstractconverter.ts
Comment thread src/converters/degiroConverterV2.ts
@dominatos

Copy link
Copy Markdown
Author

@coderabbitai help

@coderabbitai

coderabbitai Bot commented Apr 5, 2026

Copy link
Copy Markdown

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.
    • 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.
  • 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

CodeRabbit commands

These commands are invoked using PR/Issue 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 evaluate custom pre-merge check --instructions <custom-checks-instructions> --name <custom-checks-title> [--mode <error|warning>] to validate the custom pre-merge checks instructions. Defaults to error when --mode is omitted.
    • @coderabbitai ignore pre-merge checks to override pre-merge checks and get an approval on PR.
    • @coderabbitai run pre-merge checks to run pre-merge checks on the pull request.
  • @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 merge conflict to automatically resolve merge conflicts.
  • @coderabbitai autofix to automatically fix issues identified in unresolved review comments.
  • @coderabbitai resolve to resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai generate configuration to create a PR that adds the current resolved configuration as .coderabbit.yaml (or show it if already present).
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit 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.
  • You can also validate your configuration using the online YAML validator.
  • 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

Status, support, documentation and community

  • Visit our status page to check the current availability of CodeRabbit.
  • Create a ticket on our support page for assistance with any issues or questions.
  • Visit our documentation site for detailed information on how to use CodeRabbit.
  • Join our Discord community to connect with other users and get help from the community.
  • Follow us on X/Twitter for updates and announcements.

@dominatos

Copy link
Copy Markdown
Author

@coderabbitai resume

@coderabbitai

coderabbitai Bot commented Apr 5, 2026

Copy link
Copy Markdown
✅ Actions performed

Reviews resumed.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/converters/abstractconverter.ts (1)

128-129: Avoid exposing mutable internal state via getSkippedRecords().

Returning the backing array directly allows external mutation of converter internals. Prefer returning a defensive copy (and optionally a readonly type).

♻️ Suggested refinement
-    public getSkippedRecords(): SkippedRecord[] {
-        return this.skippedRecords;
-    }
+    public getSkippedRecords(): ReadonlyArray<SkippedRecord> {
+        return [...this.skippedRecords];
+    }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/converters/abstractconverter.ts` around lines 128 - 129,
getSkippedRecords currently returns the internal mutable array skippedRecords
directly, allowing callers to mutate converter internals; change
getSkippedRecords to return a defensive copy (e.g., return
[...this.skippedRecords]) or a readonly view (e.g., return
this.skippedRecords.slice() typed as ReadonlyArray<SkippedRecord>) so external
code cannot modify the backing skippedRecords array inside the class (update the
getSkippedRecords method in the AbstractConverter/abstractconverter
implementation).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/converters/abstractconverter.ts`:
- Around line 128-129: getSkippedRecords currently returns the internal mutable
array skippedRecords directly, allowing callers to mutate converter internals;
change getSkippedRecords to return a defensive copy (e.g., return
[...this.skippedRecords]) or a readonly view (e.g., return
this.skippedRecords.slice() typed as ReadonlyArray<SkippedRecord>) so external
code cannot modify the backing skippedRecords array inside the class (update the
getSkippedRecords method in the AbstractConverter/abstractconverter
implementation).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: fb1fa593-c570-4bc4-81d0-ac589839e422

📥 Commits

Reviewing files that changed from the base of the PR and between 87671c0 and 6c0f3d2.

📒 Files selected for processing (3)
  • .env.sample
  • src/converter.ts
  • src/converters/abstractconverter.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/converter.ts

When converting a CSV file, some records may be skipped because:
- The record type is intentionally ignored (e.g. deposits, withdrawals)
- No matching security symbol could be found
- The record could not be matched to a valid transaction type
- An error occurred looking up the security

This change introduces a skipped records report:
- Adds `SkippedRecord` model with line number, raw CSV line, and reason
- Adds `addSkippedRecord()` and `getSkippedRecords()` to AbstractConverter
- Updates all skip/continue paths in converters to call `addSkippedRecord()`
- After conversion, if any records were skipped, writes a
  `skipped-records-<converter>-<timestamp>.csv` file to the output folder
- Controlled by env var `GHOSTFOLIO_SHOW_SKIPPED` (default: true)
@dominatos
dominatos force-pushed the feature/skipped-records-report branch from 6c0f3d2 to aed1039 Compare April 6, 2026 00:04

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

♻️ Duplicate comments (2)
src/converters/abstractconverter.ts (1)

12-13: ⚠️ Potential issue | 🟡 Minor

Reset skippedRecords at the start of each conversion run.

Line 119 says this returns skips from the “last conversion run”, but readAndProcessFile (Line 35) does not clear prior entries. If the same converter instance is reused, reports will include stale rows.

💡 Suggested fix
 public readAndProcessFile(inputFile: string, successCallback: CallableFunction, errorCallback: CallableFunction) {

+        this.skippedRecords = [];
+
         // If the file does not exist, throw error.
         if (!fs.existsSync(inputFile)) {
             return errorCallback(new Error(`File ${inputFile} does not exist!`));
         }

Also applies to: 119-124

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/converters/abstractconverter.ts` around lines 12 - 13, The skippedRecords
array on the converter instance is not cleared between runs, causing
getSkippedRecords (lines ~119-124) to return stale entries; fix this by
resetting the private property skippedRecords = [] at the start of each
conversion run inside readAndProcessFile (or any public method that begins a
run) so every invocation begins with an empty skippedRecords collection and
subsequent pushes only reflect the current run.
src/converters/degiroConverterV2.ts (1)

26-27: ⚠️ Potential issue | 🟠 Major

Don’t derive source rows via input.split(/\r?\n/) + idx.

This breaks as soon as a valid CSV field contains embedded newlines: rawLine and lineNumber no longer match the actual parsed record, so skipped-record reports become inaccurate.

Also applies to: 76-78

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/converters/degiroConverterV2.ts` around lines 26 - 27, Don’t split the
input with input.split(/\r?\n/) to compute source rows because embedded newlines
in quoted CSV fields break line mapping; instead derive the row/line number from
the CSV parser metadata when processing each parsed record (e.g. use the
parser's info/lines or record-level metadata your CSV library exposes) in the
degiro conversion flow (replace uses of rawLines and rawLines[idx] in the
functions in degiroConverterV2.ts, including the earlier instance around the
rawLines declaration and the later uses around the record-processing logic
referenced at 76-78), and use that parser-provided line/record index in
skipped-record reports so they remain correct when fields contain embedded
newlines.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@src/converters/abstractconverter.ts`:
- Around line 12-13: The skippedRecords array on the converter instance is not
cleared between runs, causing getSkippedRecords (lines ~119-124) to return stale
entries; fix this by resetting the private property skippedRecords = [] at the
start of each conversion run inside readAndProcessFile (or any public method
that begins a run) so every invocation begins with an empty skippedRecords
collection and subsequent pushes only reflect the current run.

In `@src/converters/degiroConverterV2.ts`:
- Around line 26-27: Don’t split the input with input.split(/\r?\n/) to compute
source rows because embedded newlines in quoted CSV fields break line mapping;
instead derive the row/line number from the CSV parser metadata when processing
each parsed record (e.g. use the parser's info/lines or record-level metadata
your CSV library exposes) in the degiro conversion flow (replace uses of
rawLines and rawLines[idx] in the functions in degiroConverterV2.ts, including
the earlier instance around the rawLines declaration and the later uses around
the record-processing logic referenced at 76-78), and use that parser-provided
line/record index in skipped-record reports so they remain correct when fields
contain embedded newlines.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 37fec02a-86ca-457e-b71b-9380e7b51688

📥 Commits

Reviewing files that changed from the base of the PR and between 6c0f3d2 and cefb89e.

📒 Files selected for processing (5)
  • .env.sample
  • src/converter.ts
  • src/converters/abstractconverter.ts
  • src/converters/degiroConverterV2.ts
  • src/models/skippedRecord.ts
✅ Files skipped from review due to trivial changes (1)
  • src/models/skippedRecord.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • .env.sample
  • src/converter.ts

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