Skip to content

feat: enhance import logging - #3510

Open
TheTisiboth wants to merge 7 commits into
masterfrom
feat/enhance-import-logging
Open

TheTisiboth wants to merge 7 commits into
masterfrom
feat/enhance-import-logging

Conversation

@TheTisiboth

@TheTisiboth TheTisiboth commented Oct 26, 2026 •

Copy link
Copy Markdown
Collaborator

Addresses #3279

Followed by #3538 (stacked).

Topic and Scope

Adds logging throughout the recipe import pipeline so admins can see in nextcloud.log why an import failed. No change to API responses.

  • Log at each step: download (HTTP status, content-type, size), extraction (per-parser failure reasons)
  • ImportException carries the failing step (download, parse_html, extract_recipe), logged on failure
  • Logged URLs are stripped of credentials, query and fragment (UrlRedactionHelper)

Concerns/issues

  • ImportException new last param string $step = '' is backward-compatible
  • The debug dump feature (saving downloaded HTML to a temp folder for inspection) is out of scope and needs design discussion — see Enhance import logging #3279

Formal requirements

  • I did check that the app can still be opened and does not throw any browser logs
  • I created tests for newly added PHP code (check this if no PHP changes were made)
  • I updated the OpenAPI specs and added an entry to the API changelog (check if API was not modified)
  • I notified the matrix channel if I introduced an API change

Note

This PR was created with the assistance of AI tools.
Assisted-by: Claude Code (claude-opus-4-6, claude-opus-5-5)

🤖 Generated with Claude Code

@nextcloud-command nextcloud-command added the AI assisted This PR contains AI-assisted commits label Oct 26, 2026
@github-actions

github-actions Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Test Results

   12 files    604 suites   2m 35s ⏱️
  612 tests   604 ✅  8 💤 0 ❌
2 448 runs  2 415 ✅ 33 💤 0 ❌

Results for commit b6befe4.

♻️ This comment has been updated with latest results.

Add structured logging throughout the recipe import pipeline:
- Tag ImportExceptions with a step property (download/parse_html/extract_recipe)
- Log per-parser failures with reasons in RecipeExtractionService
- Add debug logs in HTML parsers (JSON-LD element count, decode errors, microdata itemscope count)
- Log HTTP status, content-type, and response size after download
- Return structured {msg, step} error responses from the import API
- Remove file/line leak from all error responses (import, update, create)
- Catch generic exceptions as HTTP 500 with safe translated message

Assisted-by: Claude Code (claude-opus-4-6)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Léo Jan <leo.jan@doctolib.com>
@TheTisiboth
TheTisiboth force-pushed the feat/enhance-import-logging branch from 8efea9f to e3dc968 Compare October 26, 2026 21:55
TheTisiboth and others added 2 commits October 29, 2026 19:57
…-logging

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Léo Jan <leo.jan@doctolib.com>
Assisted-by: Claude Code:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Léo Jan <leo.jan@doctolib.com>
@TheTisiboth
TheTisiboth marked this pull request as ready for review October 29, 2026 18:59
@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
Walkthrough

The import pipeline now attaches step labels to download, HTML parsing, and recipe extraction exceptions. Services and parsers log outcomes and failures with redacted URLs. The controller logs import exceptions separately from other exceptions and returns status 400 for both.

Priority: Low

Merge Risk: Low · up to b6bef

This change adds structured import logging with redacted URLs and step labels, and it does not change the HTTP status or response bodies for import failures. One small follow-up remains: an error message that includes a recipe-supplied URL can still be written to the server log unredacted. That is a narrow, conditional privacy concern that the owner can accept or fix after merge.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 76.92% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title "feat: enhance import logging" matches the main change. The changeset adds logging across the recipe import pipeline (download, HTML parsing, extraction), adds an ImportException step field,…
Description check Passed The description follows the template's main sections. It has a Topic and Scope section that explains the logging additions, the step field on ImportException, and URL redaction. It has a Concerns/issu…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "feat: enhance import logging" matches the main change. The changeset adds logging across the recipe import pipeline (download, HTML parsing, extraction), adds an ImportException step field, and adds a URL redaction helper for logged URLs. The title is short and specific, and it uses the conventional commit style.

Full details: Description check

Explanation

The description follows the template's main sections. It has a Topic and Scope section that explains the logging additions, the step field on ImportException, and URL redaction. It has a Concerns/issues section that notes the backward-compatible constructor parameter and the out-of-scope debug dump feature. All four formal requirement boxes are checked. The description is mostly complete. However, the formal requirement checkboxes claim OpenAPI spec updates and a Matrix notification, while the stated scope says no API response change. The commit messages also say the structured error response changes moved to a separate PR, which conflicts with the description's list of those changes. These conflicts do not make the description fail, but the author should reconcile them.

Full details: Docstring Coverage

Explanation

Docstring coverage is 76.92% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 13 functions across 14 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

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

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (1)

Major · Apply the generic import handler to cache insertion. · RecipeImplementation.php:326-328

lib/Controller/Implementation/RecipeImplementation.php:326-328
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Apply the generic import handler to cache insertion.

DbCacheService::addRecipe() remains outside the new generic handler. Its database and cache-update operations can raise exceptions that escape RecipeImplementation::import() and bypass the documented generic {msg} response.

This block existed before the PR, but the PR adds a broad contract that unexpected import errors return HTTP 500 with a generic message. Extend that handling to cache insertion while preserving the existing InvalidJSONFileException cleanup.


Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 4df5fdd1-4015-410b-899d-507f8b67f401
Commits

Reviewing files that changed from the base of the PR and between 56213cf and 30880c0.

Files selected for processing: 18
  • docs/dev/api/changelog/0.md
  • docs/dev/api/trunk/internal-cookbook.yaml
  • docs/dev/api/trunk/objects.yaml
  • docs/dev/api/trunk/openapi-cookbook.yaml
  • lib/Controller/Implementation/RecipeImplementation.php
  • lib/Exception/ImportException.php
  • lib/Helper/HTMLParser/AbstractHtmlParser.php
  • lib/Helper/HTMLParser/HttpJsonLdParser.php
  • lib/Helper/HTMLParser/HttpMicrodataParser.php
  • lib/Helper/HtmlToDomParser.php
  • lib/Service/HtmlDownloadService.php
  • lib/Service/RecipeExtractionService.php
  • lib/Service/RecipeService.php
  • src/components/AppNavi.vue
  • tests/Unit/Controller/Implementation/RecipeImplementationTest.php
  • tests/Unit/Helper/HTMLParser/HttpJsonLdParserTest.php
  • tests/Unit/Helper/HTMLParser/HttpMicrodataParserTest.php
  • tests/Unit/Service/RecipeExtractionServiceTest.php

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 1 remain after this review.

Comment thread lib/Service/HtmlDownloadService.php Resolved
Also document that invalid recipe JSON still returns a plain-string 400.

Assisted-by: Claude Code:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Léo Jan <leo.jan@doctolib.com>
@TheTisiboth
TheTisiboth enabled auto-merge (squash) October 29, 2026 19:43

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


Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a8fbf4f0-0f2a-4b91-b528-de93acd6c9b0
Commits

Reviewing files that changed from the base of the PR and between 30880c0 and ab1434e.

Files selected for processing: 5
  • docs/dev/api/changelog/0.md
  • docs/dev/api/trunk/internal-cookbook.yaml
  • docs/dev/api/trunk/openapi-cookbook.yaml
  • lib/Controller/Implementation/RecipeImplementation.php
  • tests/Unit/Controller/Implementation/RecipeImplementationTest.php
Files skipped from review as they are similar to previous changes: 3
  • docs/dev/api/changelog/0.md
  • docs/dev/api/trunk/openapi-cookbook.yaml
  • docs/dev/api/trunk/internal-cookbook.yaml

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.

Assisted-by: Claude Code:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Léo Jan <leo.jan@doctolib.com>

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

🔇 Additional comments: 2
lib/Service/RecipeService.php-358-358: 1

358-358: Minor · Security & Privacy · Quick win

⚠️ Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.

Do not log the recipe name.

The parsed name is user content. This new info log retains it on every successful extraction, including when the name contains private details. Log extraction success without the name. (raw.githubusercontent.com)

lib/Helper/UrlRedactionHelper.php-23-23: 1

23-23: Major · Security & Privacy · Quick win

⚠️ Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.

Remove the path from logged URLs.

If an import URL contains a token in its path, redact() retains that token. Download and parser logs then persist it. Return the scheme and host, with the port if needed, but not the path. (raw.githubusercontent.com)

Based on learnings, full URLs can embed API keys or tokens in the path.

Source: Learnings


Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c3b03ef5-3e0e-49b9-a772-3add014cab91
Commits

Reviewing files that changed from the base of the PR and between ab1434e and 873bfb7.

Files selected for processing: 8
  • lib/Controller/Implementation/RecipeImplementation.php
  • lib/Helper/HTMLParser/HttpJsonLdParser.php
  • lib/Helper/HTMLParser/HttpMicrodataParser.php
  • lib/Helper/UrlRedactionHelper.php
  • lib/Service/HtmlDownloadService.php
  • lib/Service/RecipeExtractionService.php
  • lib/Service/RecipeService.php
  • tests/Unit/Helper/UrlRedactionHelperTest.php
Files skipped from review as they are similar to previous changes: 1
  • lib/Service/HtmlDownloadService.php

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 1 remain after this review.

Validation errors of the extracted recipe returned a generic 500 instead of a 400 with the extract_recipe step.

Assisted-by: Claude Code:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Léo Jan <leo.jan@doctolib.com>

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


Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2a7d43ac-5502-4fcc-9fa4-02886edc6737
Commits

Reviewing files that changed from the base of the PR and between 873bfb7 and 9389b3a.

Files selected for processing: 2
  • lib/Service/RecipeService.php
  • tests/Unit/Controller/Implementation/RecipeImplementationTest.php

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 0 remain after this review.

Comment thread lib/Service/RecipeService.php Resolved
Keep this change focused on import logging. Response format, API docs and frontend handling follow in a stacked PR.

Assisted-by: Claude Code:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Léo Jan <leo.jan@doctolib.com>
@TheTisiboth TheTisiboth changed the title feat: enhance import logging and error reporting feat: enhance import logging Oct 29, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI assisted This PR contains AI-assisted commits

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants