Skip to content

Conversation

@AgustinSilverfin
Copy link
Contributor

Fixes # (link to the corresponding issue if applicable)

Description

Include a summary of the changes made

Testing Instructions

Steps:

  1. ...
  2. ...
  3. ...

Author Checklist

  • Skip bumping the CLI version

Reviewer Checklist

  • PR has a clear title and description
  • Manually tested the changes that the PR introduces
  • Changes introduced are covered by tests of acceptable quality

@AgustinSilverfin AgustinSilverfin self-assigned this Sep 10, 2025
Copy link
Contributor

@michieldegezelle michieldegezelle left a comment

Choose a reason for hiding this comment

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

Couple of questions about adding returns in certain conditions, but apart from that, all good! Very nice addition!

@AgustinSilverfin AgustinSilverfin force-pushed the agustin-generate-export-file branch from 6f95fb4 to ebee28c Compare January 7, 2026 14:20
@coderabbitai
Copy link

coderabbitai bot commented Jan 7, 2026

Warning

Rate limit exceeded

@AgustinSilverfin has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 15 minutes and 19 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 9a59736 and 10eef46.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (7)
  • CHANGELOG.md
  • bin/cli.js
  • lib/api/sfApi.js
  • lib/cli/cliUpdater.js
  • lib/exportFileInstanceGenerator.js
  • lib/utils/urlHandler.js
  • package.json

Walkthrough

Adds a new CLI command generate-export-file plus supporting modules: ExportFileInstanceGenerator (generation, polling, validation logging), UrlHandler (download & open), two SF API functions, changelog and version bump, and a minor formatting tweak.

Changes

Cohort / File(s) Summary
CLI command
bin/cli.js
Adds generate-export-file command requiring --firm, --company, --period, --export-file; imports and uses ExportFileInstanceGenerator (note: command block appears duplicated).
Export file generator
lib/exportFileInstanceGenerator.js
New ExportFileInstanceGenerator class: validates ctor args, calls SF API to create instance, polls status (initial 1000ms, max 5000ms, up to 25 attempts), logs validation errors, and opens content URL; exported.
URL handling utility
lib/utils/urlHandler.js
New UrlHandler class: downloads URL with Axios, derives extension from content-disposition, writes timestamped temp file under OS tmpdir/silverfin, and opens it; exported.
API additions
lib/api/sfApi.js
Adds createExportFileInstance(firmId, companyId, periodId, exportFileId) and getExportFileInstance(firmId, companyId, periodId, exportFileInstanceId) (POST/GET) and exports them.
Docs & metadata
CHANGELOG.md, package.json
Adds 1.50.0 changelog entry for the new CLI command and bumps version to 1.50.0; minor reflow in prior changelog entry.
Formatting tweak
lib/cli/cliUpdater.js
Inserted a blank line after an import; no behavioral change.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description check ⚠️ Warning The pull request description is incomplete—it contains only template placeholders without any actual implementation details, testing steps, or issue references filled in. Replace template placeholders with concrete details: link the issue, summarize the changes (new CLI command, ExportFileInstanceGenerator class, UrlHandler utility), and provide actual testing steps instead of placeholder '1. ... 2. ... 3. ...' entries.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat: new command to generate export file instances' clearly describes the main change: a new CLI command for generating export file instances, which matches the primary functionality added across bin/cli.js, lib/exportFileInstanceGenerator.js, and lib/utils/urlHandler.js.

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


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.

@AgustinSilverfin AgustinSilverfin force-pushed the agustin-generate-export-file branch 2 times, most recently from ca842af to f603cb1 Compare January 7, 2026 14:24
Copy link

@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: 6

🤖 Fix all issues with AI agents
In @bin/cli.js:
- Around line 718-729: The CLI command for "generate-export-file" calls
ExportFileInstanceGenerator.generateAndOpenFile() but doesn't await its
asynchronous completion; update the command handler so the .action callback
awaits the async method (e.g., change the call to await
generator.generateAndOpenFile()) and ensure the action is declared async
(already is) and propagate or catch errors (handle rejections) so the process
does not exit before the operation completes and any errors are surfaced.

In @CHANGELOG.md:
- Line 7: In the 1.50.0 changelog sentence describing `silverfin
generate-export-file`, fix the grammar by changing both instances of "etc" to
"etc." (ensure the period appears before the closing parenthesis where
applicable, e.g., "CSV, etc.)") and correct the typo "runnig" to "running",
making sure the sentence ends with a final period.

In @lib/exportFileInstanceGenerator.js:
- Around line 52-71: The polling loop in #generateInstance (the while using
this.#MAX_ATTEMPTS) can fall through and return undefined when all attempts stay
"pending"; add a clear failure return after the loop: after the while block log
an error with consola.error (including this.#details(exportFileInstanceId)) and
return false (or throw if you prefer), ensuring callers like
#logValidationErrors and #openUrl receive a defined failure value instead of
undefined.
- Around line 88-94: The private method #openUrl currently calls
UrlHandler.openFile() without awaiting it, which can let the process exit before
the async file open/download completes; change the call in #openUrl to await new
UrlHandler(response.content_url).openFile() and mark #openUrl as async if it
isn't, and update the callers (notably generateAndOpenFile()) to await
this.#openUrl(...) so the async flow is properly propagated.

In @lib/utils/urlHandler.js:
- Line 35: Remove the leftover debug statement by deleting the
console.log(response) call in lib/utils/urlHandler.js (the stray
console.log(response) that prints the full Axios response object); if needed,
replace it with an appropriate logger.debug or a more specific log (e.g.,
logging response.status or response.data) consistent with existing logging in
the module, but do not leave console.log(response) in production code.
- Around line 31-44: In #downloadFile, fix binary corruption and potential
TypeError by requesting the response as binary and guarding the header: call
axios.get(this.url, { responseType: "arraybuffer" }) (or "stream" if preferred),
pass (response.headers["content-disposition"] || "") into #identifyExtension so
it never receives undefined, and write the file as binary (e.g.,
fs.writeFileSync(tempFilePath, Buffer.from(response.data))) instead of relying
on default text handling; also remove the stray console.log(response).
🧹 Nitpick comments (4)
bin/cli.js (1)

722-725: Consider validating firm ID and using consistent option shorthands.

  1. Unlike other commands, this doesn't call cliUtils.checkDefaultFirm() to validate the firm option.
  2. The -p shorthand is used for --period here but for --partner in all other commands, which may confuse users.
♻️ Suggested improvements
   .command("generate-export-file")
   .description("Create a new export file instance from an export file template (e.g. (i)XBRL)")
   .option("-f, --firm <firm-id>", "Specify the firm to be used", firmIdDefault)
   .requiredOption("-c, --company <company-id>", "Specify the company to be used")
-  .requiredOption("-p, --period <period-id>", "Specify the period to be used")
+  .requiredOption("--period <period-id>", "Specify the period to be used")
   .requiredOption("-e, --export-file <export-file-id>", "Specify the export file template to be used")
   .action(async (options) => {
+    cliUtils.checkDefaultFirm(options.firm, firmIdDefault);
     const generator = new ExportFileInstanceGenerator(options.firm, options.company, options.period, options.exportFile);
     await generator.generateAndOpenFile();
   });
lib/utils/urlHandler.js (2)

46-49: Remove unnecessary async and improve robustness.

This method performs no async operations and should be synchronous. The regex also won't handle all content-disposition formats (e.g., filename*=UTF-8''... encoding).

♻️ Proposed fix
-  async #identifyExtension(url) {
-    const match = url.match(/filename[*]?=['"]?(?:[^'"]*\.)?([^.'";\s]+)['"]/i);
+  #identifyExtension(contentDisposition) {
+    if (!contentDisposition) return null;
+    const match = contentDisposition.match(/filename[*]?=['"]?(?:[^'"]*\.)?([^.'";\s]+)['"]/i);
     return match ? match[1] : null;
   }

36-36: Consider including a meaningful filename.

Currently the file is saved as just a timestamp (e.g., 1704672000000.xml). Consider extracting the original filename from the content-disposition header to provide a more meaningful name for users.

lib/exportFileInstanceGenerator.js (1)

28-36: Consider short-circuiting on failure.

If #generateInstance() returns false or undefined, the code still proceeds to call #logValidationErrors and #openUrl, which will just log an error. Consider returning early on failure for cleaner flow.

♻️ Suggested improvement
   async generateAndOpenFile() {
     try {
       const response = await this.#generateInstance();
+      if (!response) {
+        return;
+      }
       this.#logValidationErrors(response);
-      this.#openUrl(response);
+      await this.#openUrl(response);
     } catch (error) {
       errorUtils.errorHandler(error);
     }
   }
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9b78203 and ebee28c.

📒 Files selected for processing (7)
  • CHANGELOG.md
  • bin/cli.js
  • lib/api/sfApi.js
  • lib/cli/cliUpdater.js
  • lib/exportFileInstanceGenerator.js
  • lib/utils/urlHandler.js
  • package.json
🧰 Additional context used
🧬 Code graph analysis (2)
lib/utils/urlHandler.js (1)
lib/exportFileInstanceGenerator.js (3)
  • require (2-2)
  • require (4-4)
  • errorUtils (3-3)
lib/api/sfApi.js (2)
lib/liquidTestRunner.js (1)
  • response (209-209)
index.js (15)
  • response (151-151)
  • response (187-187)
  • response (220-220)
  • response (351-351)
  • response (386-386)
  • response (418-418)
  • response (548-548)
  • response (589-589)
  • response (628-628)
  • response (679-679)
  • response (753-753)
  • response (788-788)
  • response (821-821)
  • response (887-887)
  • response (1045-1045)
🪛 GitHub Actions: CLI version check
package.json

[error] 1-1: Version check failed: current branch version (1.50.0) must be greater than main branch version (1.49.0).

🪛 LanguageTool
CHANGELOG.md

[style] ~7-~7: In American English, abbreviations like “etc.” require a period.
Context: ...on of export files (XBRLs, iXBRLs, CSV, etc) with the CLI. This could be used as pa...

(ETC_PERIOD)


[style] ~7-~7: In American English, abbreviations like “etc.” require a period.
Context: ...ault application (browser, text editor, etc). See more details on how to use it by ...

(ETC_PERIOD)


[grammar] ~7-~7: Ensure spelling is correct
Context: ...). See more details on how to use it by runnig silverfin generate-export-file --help...

(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)

🔇 Additional comments (5)
lib/cli/cliUpdater.js (1)

7-8: LGTM! Minor formatting adjustment adds spacing after imports, which improves readability.

package.json (1)

3-3: Version bump is correct, but pipeline failure needs investigation.

The version change from 1.49.0 → 1.50.0 is appropriate for a new feature and satisfies the semantic versioning constraint. However, the GitHub Actions pipeline reports: "Version check failed: current branch version (1.50.0) must be greater than main branch version (1.49.0)."

Since 1.50.0 is greater than 1.49.0, this appears to be either a pipeline configuration issue or a timing issue with the main branch version cache. Verify that the pipeline passes after merge or check the version-check workflow configuration.

CHANGELOG.md (1)

9-15: Changelog formatting looks good. The adjustments to the 1.49.0 and 1.48.0 entries maintain consistency with existing entries and improve clarity.

lib/api/sfApi.js (1)

644-666: LGTM!

Both createExportFileInstance and getExportFileInstance follow the established patterns in this file for API calls, error handling, and response processing. The implementation is consistent with similar functions like readExportFileById.

lib/exportFileInstanceGenerator.js (1)

10-12: LGTM on polling configuration.

The exponential-like backoff (1s initial, +1s per attempt, max 5s) with 25 max attempts provides a reasonable ~75-125 second total wait time for export file generation.

@AgustinSilverfin AgustinSilverfin force-pushed the agustin-generate-export-file branch from f603cb1 to 9a59736 Compare January 7, 2026 14:26
Copy link

@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: 2

🤖 Fix all issues with AI agents
In @bin/cli.js:
- Around line 718-729: The action handler invokes
ExportFileInstanceGenerator.generateAndOpenFile() without awaiting its async
result; update the action to await the call (e.g., await
generator.generateAndOpenFile()) so the CLI waits for completion, and wrap the
await in a try/catch to log errors and set a non-zero exit code if the async
operation fails—look for the program.command("generate-export-file") block and
the ExportFileInstanceGenerator.generateAndOpenFile reference to apply the
change.

In @CHANGELOG.md:
- Line 7: Update the changelog sentence describing the new CLI command
`silverfin generate-export-file`: correct the two occurrences of "etc" to "etc."
and fix the typo "runnig" to "running" so the paragraph reads with proper
punctuation and spelling.
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ebee28c and f603cb1.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (7)
  • CHANGELOG.md
  • bin/cli.js
  • lib/api/sfApi.js
  • lib/cli/cliUpdater.js
  • lib/exportFileInstanceGenerator.js
  • lib/utils/urlHandler.js
  • package.json
🚧 Files skipped from review as they are similar to previous changes (3)
  • lib/utils/urlHandler.js
  • lib/exportFileInstanceGenerator.js
  • lib/cli/cliUpdater.js
🧰 Additional context used
🪛 GitHub Actions: CLI version check
CHANGELOG.md

[error] 1-1: Changelog entry for version 1.50.0 is missing. The CI step that verifies the changelog failed with exit code 1.

🪛 LanguageTool
CHANGELOG.md

[style] ~7-~7: In American English, abbreviations like “etc.” require a period.
Context: ...on of export files (XBRLs, iXBRLs, CSV, etc) with the CLI. This could be used as pa...

(ETC_PERIOD)


[style] ~7-~7: In American English, abbreviations like “etc.” require a period.
Context: ...ault application (browser, text editor, etc). See more details on how to use it by ...

(ETC_PERIOD)


[grammar] ~7-~7: Ensure spelling is correct
Context: ...). See more details on how to use it by runnig silverfin generate-export-file --help...

(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)

🔇 Additional comments (7)
package.json (1)

3-3: LGTM!

The version bump to 1.50.0 is appropriate for the new export file generation feature.

lib/api/sfApi.js (3)

644-654: LGTM!

The createExportFileInstance function follows the established patterns in this module, with consistent error handling and response structure.


656-666: LGTM!

The getExportFileInstance function is correctly implemented and follows the module's conventions.


717-718: LGTM!

The new functions are properly exported and integrated into the module's public API.

bin/cli.js (1)

6-6: LGTM!

The import statement correctly brings in the ExportFileInstanceGenerator class.

CHANGELOG.md (2)

5-5: Verify the release date.

The changelog entry is dated "07/01/2026", but the PR was created on 2025-09-10. Please confirm this date is correct.


5-8: Remove this comment — the changelog entry is correctly formatted.

The actual CHANGELOG.md entry is ## [1.50.0] (07/01/2026) with square brackets, which matches the CI validation requirement. The snippet shown in your review is incorrect; it displays the version without brackets. No CI failure exists for this entry.

Likely an incorrect or invalid review comment.

Copy link

@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: 1

🤖 Fix all issues with AI agents
In @bin/cli.js:
- Around line 726-729: The CLI action is calling the async method
generateAndOpenFile() on ExportFileInstanceGenerator without awaiting it, which
can let the process exit before completion; update the .action handler to await
generator.generateAndOpenFile() (e.g., await generator.generateAndOpenFile();)
and optionally wrap it in a try/catch to propagate or log errors from the async
call so failures aren’t lost.
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f603cb1 and 9a59736.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (7)
  • CHANGELOG.md
  • bin/cli.js
  • lib/api/sfApi.js
  • lib/cli/cliUpdater.js
  • lib/exportFileInstanceGenerator.js
  • lib/utils/urlHandler.js
  • package.json
🚧 Files skipped from review as they are similar to previous changes (4)
  • lib/cli/cliUpdater.js
  • lib/exportFileInstanceGenerator.js
  • lib/utils/urlHandler.js
  • package.json
🧰 Additional context used
🪛 LanguageTool
CHANGELOG.md

[style] ~7-~7: In American English, abbreviations like “etc.” require a period.
Context: ...on of export files (XBRLs, iXBRLs, CSV, etc) with the CLI. This could be used as pa...

(ETC_PERIOD)


[style] ~7-~7: In American English, abbreviations like “etc.” require a period.
Context: ...ault application (browser, text editor, etc). See more details on how to use it by ...

(ETC_PERIOD)


[grammar] ~7-~7: Ensure spelling is correct
Context: ...). See more details on how to use it by runnig silverfin generate-export-file --help...

(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)

🔇 Additional comments (5)
lib/api/sfApi.js (3)

644-654: LGTM!

The function follows the established pattern in this file: creates a firm instance, makes a POST request to the correct endpoint, handles success/error cases, and returns the appropriate data structure.


656-666: LGTM!

The function correctly follows the established pattern: creates a firm instance, makes a GET request to fetch the specific export file instance, handles success/error cases, and returns the data structure.


717-718: LGTM!

The new functions are correctly added to the module exports, maintaining consistency with the existing export structure.

bin/cli.js (1)

6-6: LGTM!

The import statement correctly brings in the ExportFileInstanceGenerator class using destructuring, consistent with the file's import patterns.

CHANGELOG.md (1)

7-7: Fix grammar and spelling issues (already flagged).

The changelog description needs corrections as previously noted:

  • "etc" should be "etc." (appears twice)
  • "runnig" should be "running"

Likely an incorrect or invalid review comment.

@AgustinSilverfin AgustinSilverfin force-pushed the agustin-generate-export-file branch from 9a59736 to d4ab1df Compare January 7, 2026 14:32
@AgustinSilverfin AgustinSilverfin force-pushed the agustin-generate-export-file branch from d4ab1df to 10eef46 Compare January 7, 2026 14:35
Copy link
Contributor

@michieldegezelle michieldegezelle left a comment

Choose a reason for hiding this comment

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

Two nitpick questions left, but approving already since these are not blocking/wrong

@AgustinSilverfin AgustinSilverfin merged commit 841a330 into main Jan 8, 2026
3 checks passed
@AgustinSilverfin AgustinSilverfin deleted the agustin-generate-export-file branch January 8, 2026 09:59
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.

3 participants