GithubHelp home page GithubHelp logo

Comments (4)

kontrollanten avatar kontrollanten commented on September 21, 2024

Describe the current behavior

Currently the client can send float value to POST /api/v1/videos/{id}/views, which isn't accepted by the API due to validators.isInt check

return value === null || validator.default.isInt('' + value)

isInt returns false when passing a float value:

validator.isInt('13.12123123')
false

The client code that's sending the float is probably this:

this.videoViewOnPlayHandler = () => {
debugLogger('Notify user is watching on play: ' + startTime)
this.notifyUserIsWatching(startTime, lastViewEvent)
}

Describe the expected behavior

Either the client should send an int or the API should be more forgiving and converting float to int.

Additional information

  • PeerTube instance:

    • URL:
    • Version: 6.0.3
    • NodeJS version:
    • Ffmpeg version:
  • Browser name, version and platforms on which you could reproduce the bug:

  • Link to browser console log if relevant:

  • Link to server log if relevant (journalctl or /var/www/peertube/storage/logs/):

from peertube.

Chocobozzz avatar Chocobozzz commented on September 21, 2024

Currently the client can send float value to POST /api/v1/videos/{id}/views, which isn't accepted by the API due to validators.isInt check

Are you sure? In your example I don't see where startTime can be a float, and other notifyUserIsWatching calls use Math.floor (like https://github.com/Chocobozzz/PeerTube/blob/develop/client/src/assets/player/shared/peertube/peertube-plugin.ts#L350)

from peertube.

kontrollanten avatar kontrollanten commented on September 21, 2024

Yes, at least we see that the REST API receives floats from the web client.

In peertube-plugin.ts startTime is defined in two places:

const startTime = timeToInt(this.options.startTime())

const startTime = this.options.startTime()

The first one is using timeToInt for a reason I guess? I haven't dug deep into this, I've just noticed we receive floats from the web client in our error logs.

from peertube.

Chocobozzz avatar Chocobozzz commented on September 21, 2024

Thanks, then I think ca889db will fix the issue. Don't hesitate to comment if you still notice bad requests after applying this patch (don't forget some web browser may still have the old client in cache/as pwa so the user agent can help)

from peertube.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.