While updating with API (/api/pages/{id}) Revision-Counter increases, but not the Content and not the Revision List #4410

Closed
opened 2026-02-05 08:49:49 +03:00 by OVERLORD · 8 comments
Owner

Originally created by @DarthDestroyer on GitHub (Jan 16, 2024).

Describe the Bug

We created a small Script, updating a Page with HTML Content.

function Change-BookstackPage {
    param(
        [Parameter(Mandatory=$true)]
        [string]$Html,

        [Parameter(Mandatory=$true)]
        [int]$pageID
    )

    # Create the data to send to the API
    $body = @{
        html = $Html
    } | ConvertTo-Json

    # Ready the HTTP headers, including our auth header
    $authHeader = "Token {0}:{1}" -f $tokenId, $tokenSecret
    $headers = @{
        "Content-Type" = "application/json"
        "Authorization" = $authHeader
    }

    # Send the request to our API endpoint as a POST request
    $url = "{0}/api/pages/{1}" -f $baseUrl, $pageID
    Invoke-RestMethod -Uri $url -ContentType "application/json" -Method Put -Headers $headers -Body $body
}

The HTML Content is around 200.000 Chars long...

It has seemed to work, so we continued but now to the Problem!
When we start the Script, everything looks good - no errors, no failure or any negativ result.

The Revision Counter increases, the Content does not Change and no entry at all is shown in the Revision Overview!

That is all through Powershell! When we test the same Request with Postman (same body-content) everything seems fine!

Revision Overview
image

Result from Postman (same result in Powershell)
image

Steps to Reproduce

  • Run a Powershell Script with that Function,
  • add Change-BookstackPage $longHTMLContent {pageID}
  • See no Change and increasing Revision Number

Expected Behaviour

  • Page Content updating
  • Revision Counter increasing
  • Revision Overview listing Changes

Screenshots or Additional Context

No response

Browser Details

No response

Exact BookStack Version

v23.12.1

Originally created by @DarthDestroyer on GitHub (Jan 16, 2024). ### Describe the Bug We created a small Script, updating a Page with HTML Content. ``` function Change-BookstackPage { param( [Parameter(Mandatory=$true)] [string]$Html, [Parameter(Mandatory=$true)] [int]$pageID ) # Create the data to send to the API $body = @{ html = $Html } | ConvertTo-Json # Ready the HTTP headers, including our auth header $authHeader = "Token {0}:{1}" -f $tokenId, $tokenSecret $headers = @{ "Content-Type" = "application/json" "Authorization" = $authHeader } # Send the request to our API endpoint as a POST request $url = "{0}/api/pages/{1}" -f $baseUrl, $pageID Invoke-RestMethod -Uri $url -ContentType "application/json" -Method Put -Headers $headers -Body $body } ``` The HTML Content is around 200.000 Chars long... It has seemed to work, so we continued but now to the Problem! When we start the Script, everything looks good - no errors, no failure or any negativ result. The Revision Counter increases, the Content does not Change and no entry at all is shown in the Revision Overview! That is all through Powershell! When we test the same Request with Postman (same body-content) everything seems fine! Revision Overview ![image](https://github.com/BookStackApp/BookStack/assets/16085323/33b45c2f-2f9f-4659-956c-d5d93602af06) Result from Postman (same result in Powershell) ![image](https://github.com/BookStackApp/BookStack/assets/16085323/95f76f8f-fa75-4a6d-82cd-573e1381c842) ### Steps to Reproduce - Run a Powershell Script with that Function, - add Change-BookstackPage $longHTMLContent {pageID} - See no Change and increasing Revision Number ### Expected Behaviour - Page Content updating - Revision Counter increasing - Revision Overview listing Changes ### Screenshots or Additional Context _No response_ ### Browser Details _No response_ ### Exact BookStack Version v23.12.1
OVERLORD added the 🐛 Bug label 2026-02-05 08:49:49 +03:00
Author
Owner

@DarthDestroyer commented on GitHub (Jan 16, 2024):

When i set the same HTML Content with the Editor - everything works, too!

@DarthDestroyer commented on GitHub (Jan 16, 2024): When i set the same HTML Content with the Editor - everything works, too!
Author
Owner

@ssddanbrown commented on GitHub (Jan 16, 2024):

The only thing I can see in your code from a quick scan without running, is that the ContentType is set twice. Powershell 7.4 adds specific handling for that, but not sure what happens on previous versions. If using an older powershell version, might be worth removing one of these to see if things change.

@ssddanbrown commented on GitHub (Jan 16, 2024): The only thing I can see in your code from a quick scan without running, is that the ContentType is set twice. Powershell 7.4 adds specific handling for that, but not sure what happens on previous versions. If using an older powershell version, might be worth removing one of these to see if things change.
Author
Owner

@DarthDestroyer commented on GitHub (Jan 16, 2024):

Tried without before, had seen a Post about Powershell to set it... But it made no difference at all

Thanks for your check!

I dont understand it at the Moment!
Why does it not fail? Why is it increasing the rev-counter and why is there no content change?

Any Log, i can provide or look at?

@DarthDestroyer commented on GitHub (Jan 16, 2024): Tried without before, had seen a Post about Powershell to set it... But it made no difference at all Thanks for your check! I dont understand it at the Moment! Why does it not fail? Why is it increasing the rev-counter and why is there no content change? Any Log, i can provide or look at?
Author
Owner

@DarthDestroyer commented on GitHub (Jan 17, 2024):

I would say, powershell is the problem here...

when i call a php script, which does nothing else as reading the same request and reissue it against the api - same content, same url, same page, also on PUT Method - it works fine!

Cant find the Issue in Powershell... =/

@DarthDestroyer commented on GitHub (Jan 17, 2024): I would say, powershell is the problem here... when i call a php script, which does nothing else as reading the same request and reissue it against the api - same content, same url, same page, also on PUT Method - it works fine! Cant find the Issue in Powershell... =/
Author
Owner

@DarthDestroyer commented on GitHub (Jan 17, 2024):

Back to the Roots... Same Result!

It does not seem to be a Rate-Limit, there would be an error - or not?

@DarthDestroyer commented on GitHub (Jan 17, 2024): Back to the Roots... Same Result! It does not seem to be a Rate-Limit, there would be an error - or not?
Author
Owner

@DarthDestroyer commented on GitHub (Jan 19, 2024):

Nevermind... I've found the Problem!

It is/was powershell!

Problem here and with the example, is this Function ConvertTo-Json!

Microsoft changed the behavior for escaping at some Version!
The tested 5.1 powershell Version failed, because of escaping html to
group\u003e \u003ctr\u003e\u003cth\u003eDisplayName\u003c/th\u003e\u003cth\u003eDepartment\u

with powershell 7 to
group> <tr><th>DisplayName</th><th>Department</th>

All these Characters brought bookstack out of mind!
Like i said, everything seems to work! No Error... Increasing Rev-Counter but no Entry in the Revision-List

Maybe, this helps someone someday - Probably it could / shoud get catched, as an error!

@DarthDestroyer commented on GitHub (Jan 19, 2024): Nevermind... I've found the Problem! It is/was powershell! Problem here and with the example, is this Function ConvertTo-Json! Microsoft changed the behavior for escaping at some Version! The tested 5.1 powershell Version failed, because of escaping html to `group\u003e \u003ctr\u003e\u003cth\u003eDisplayName\u003c/th\u003e\u003cth\u003eDepartment\u` with powershell 7 to `group> <tr><th>DisplayName</th><th>Department</th>` All these Characters brought bookstack out of mind! Like i said, everything seems to work! No Error... Increasing Rev-Counter but no Entry in the Revision-List Maybe, this helps someone someday - Probably it could / shoud get catched, as an error!
Author
Owner

@ssddanbrown commented on GitHub (Jan 22, 2024):

Thanks for sharing your findings @DarthDestroyer.
from my testing, BookStack should work fine with unicode escapes in JSON content, but it may have been something specific in the exact content you had, and/or the exact resultant formatting.

Since this is resolved I'll close this off.
If anyone finds a specific issue with unicode escapes in JSON, feel free to raise via a specific issue.
In regard to the revision count, that can occur. The page revision count increments on any change, whereas a revision is only stored when a change is made to the name/html, or a summary has been set. There's existing issue #2373 related to problematic revision numbering that I'd consider this to be part of, I'll reference this issue to make that part of revision numbering a consideration there too.

@ssddanbrown commented on GitHub (Jan 22, 2024): Thanks for sharing your findings @DarthDestroyer. from my testing, BookStack should work fine with unicode escapes in JSON content, but it may have been something specific in the exact content you had, and/or the exact resultant formatting. Since this is resolved I'll close this off. If anyone finds a specific issue with unicode escapes in JSON, feel free to raise via a specific issue. In regard to the revision count, that can occur. The page revision count increments on any change, whereas a revision is only stored when a change is made to the name/html, or a summary has been set. There's existing issue #2373 related to problematic revision numbering that I'd consider this to be part of, I'll reference this issue to make that part of revision numbering a consideration there too.
Author
Owner

@DarthDestroyer commented on GitHub (Jan 22, 2024):

I just pushed html code and it has changed through the revisions... Thats what i've meant with "when i edit the page and change the html by hand" and it does change after that.

@DarthDestroyer commented on GitHub (Jan 22, 2024): I just pushed html code and it has changed through the revisions... Thats what i've meant with "when i edit the page and change the html by hand" and it does change after that.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#4410