Skip to content

Add optional file overwrite with webhook response#4

Merged
batonac merged 5 commits intomainfrom
copilot/add-overwrite-response-feature
Dec 18, 2025
Merged

Add optional file overwrite with webhook response#4
batonac merged 5 commits intomainfrom
copilot/add-overwrite-response-feature

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Dec 18, 2025

Adds OVERWRITE_WITH_RESPONSE flag to enable overwriting watched XML files with webhook server responses. When enabled with INCLUDE_CONTENT=true, the watcher sends file content to the server and replaces the original file with the response.

Implementation

  • New environment variable: OVERWRITE_WITH_RESPONSE (default: false)
  • Response validation: Requires 2xx status, XML content-type (text/xml or application/xml), non-empty body
  • Recursive trigger prevention: Temporary ignore list (2s) prevents self-triggered webhooks after file modification
  • Configuration validation: Warns at startup if overwrite enabled without content inclusion

Example Usage

docker run -d \
  -v /path/to/watch:/watch \
  -e WEBHOOK_URL="https://api.example.com/process" \
  -e INCLUDE_CONTENT="true" \
  -e OVERWRITE_WITH_RESPONSE="true" \
  xml-watcher:latest

Server receives XML content in webhook payload, returns transformed XML with Content-Type: application/xml, watcher overwrites original file without triggering new event.

Original prompt

This section details on the original issue you should resolve

<issue_title>Optional ability to overwrite with response</issue_title>
<issue_description>If enabled with a runtime flag (including send content), the watcher should overwrite the contents of the sent file with the response from the server. Of course, the response content type and status code should align. This should, of course, override the watched file without triggering a new watch event. </issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits December 18, 2025 01:41
Co-authored-by: batonac <4996285+batonac@users.noreply.github.com>
Co-authored-by: batonac <4996285+batonac@users.noreply.github.com>
Copilot AI changed the title [WIP] Add optional ability to overwrite with response Add optional file overwrite with webhook response Dec 18, 2025
Copilot AI requested a review from batonac December 18, 2025 01:49
@batonac batonac requested a review from Copilot December 18, 2025 11:15
Copy link
Copy Markdown
Contributor

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 PR adds an optional file overwrite feature that allows the XML watcher to replace watched files with webhook server responses. When enabled with OVERWRITE_WITH_RESPONSE=true and INCLUDE_CONTENT=true, the watcher sends file content to the webhook server and overwrites the original file with the response if it's valid XML with a 2xx status code.

Key Changes:

  • New OVERWRITE_WITH_RESPONSE environment variable enables response-based file overwriting
  • Temporary ignore list mechanism (2-second duration) prevents recursive webhook triggers after file modification
  • Response validation ensures proper XML content-type and non-empty body before overwriting

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/main.rs Implements overwrite logic with ignore list for preventing recursive triggers, adds configuration validation
README.md Documents the new feature with requirements and usage examples

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread README.md Outdated
Comment thread src/main.rs Outdated
batonac and others added 2 commits December 18, 2025 06:18
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@batonac batonac marked this pull request as ready for review December 18, 2025 12:07
@batonac batonac merged commit f70fa36 into main Dec 18, 2025
1 check passed
@batonac batonac deleted the copilot/add-overwrite-response-feature branch December 19, 2025 01:56
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.

Optional ability to overwrite with response

3 participants