nextcloud / news

đź“° RSS/Atom feed reader
https://apps.nextcloud.com/apps/news
GNU Affero General Public License v3.0
866 stars 185 forks source link

can't subscribe to feed #1403

Closed marco44 closed 2 years ago

marco44 commented 3 years ago

IMPORTANT

Read and tick the following checkbox after you have created the issue or place an x inside the brackets ;)

Explain the Problem

Can't subscribe to a feed anymore

Steps to Reproduce

Add a feed Get this error:

[index] Error: Doctrine\DBAL\Exception\NotNullConstraintViolationException: An exception occurred while executing a query: SQLSTATE[23502]: Not null violation: 7 ERROR:  null value in column "url_hash" of relation "oc_news_feeds" violates not-null constraint
DETAIL:  Failing row contains (145, marc, 1623254230369270, null, null, //mikrotik.com/download.rss, MikroTik Download, https://mikrotik.com/, , null, 1623254230, 20, 0, null, null, null, 0, 6, f, f, f, 0, 0). at <<closure>>

 0. /mnt/data/nextcloud/3rdparty/doctrine/dbal/src/Connection.php line 1728
    Doctrine\DBAL\Driver\API\PostgreSQL\ExceptionConverter->convert(Doctrine\DBAL\Driver\PDO\Exception {}, Doctrine\DBAL\Query {})
 1. /mnt/data/nextcloud/3rdparty/doctrine/dbal/src/Connection.php line 1667
    Doctrine\DBAL\Connection->handleDriverException(Doctrine\DBAL\Driver\PDO\Exception {}, Doctrine\DBAL\Query {})
 2. /mnt/data/nextcloud/3rdparty/doctrine/dbal/src/Connection.php line 1146
    Doctrine\DBAL\Connection->convertExceptionDuringQuery(Doctrine\DBAL\Driver\PDO\Exception {}, "INSERT INTO \"o ... )", ["MikroTik Downl ... "], [2,2,2,2,1,"And  ... "])
 3. /mnt/data/nextcloud/lib/private/DB/Connection.php line 257
    Doctrine\DBAL\Connection->executeStatement("INSERT INTO \"o ... )", ["MikroTik Downl ... "], [2,2,2,2,1,"And  ... "])
 4. /mnt/data/nextcloud/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php line 213
    OC\DB\Connection->executeStatement("INSERT INTO \"o ... )", {0: "And 5 more  ... 0}, {0: "And 5 more  ... 1})
 5. /mnt/data/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php line 287
    Doctrine\DBAL\Query\QueryBuilder->execute()
 6. /mnt/data/nextcloud/lib/public/AppFramework/Db/QBMapper.php line 135
    OC\DB\QueryBuilder\QueryBuilder->execute()
 7. /mnt/data/nextcloud/apps/news/lib/Db/NewsMapperV2.php line 76
    OCP\AppFramework\Db\QBMapper->insert(OCA\News\Db\Feed {items: [],id: null})
 8. /mnt/data/nextcloud/apps/news/lib/Service/FeedServiceV2.php line 235
    OCA\News\Db\NewsMapperV2->insert(OCA\News\Db\Feed {items: [],id: null})
 9. /mnt/data/nextcloud/apps/news/lib/Controller/FeedController.php line 176
    OCA\News\Service\FeedServiceV2->create("marc", "//mikrotik.com/download.rss", 6, false, null, null, null, true)
10. /mnt/data/nextcloud/lib/private/AppFramework/Http/Dispatcher.php line 218
    OCA\News\Controller\FeedController->create("https://mikrotik.com/download.rss", 6, null, null, null, true)
11. /mnt/data/nextcloud/lib/private/AppFramework/Http/Dispatcher.php line 127
    OC\AppFramework\Http\Dispatcher->executeController(OCA\News\Controller\FeedController {}, "create")
12. /mnt/data/nextcloud/lib/private/AppFramework/App.php line 157
    OC\AppFramework\Http\Dispatcher->dispatch(OCA\News\Controller\FeedController {}, "create")
13. /mnt/data/nextcloud/lib/private/Route/Router.php line 302
    OC\AppFramework\App::main("OCA\\News\\Controller\\FeedController", "create", OC\AppFramework\ ... {}, {_route: "news.feed.create"})
14. /mnt/data/nextcloud/lib/base.php line 993
    OC\Route\Router->match("/apps/news/feeds")
15. /mnt/data/nextcloud/index.php line 37
    OC::handleRequest()

url_hash is indeed a column of the table and "not null"

System Information

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

marco44 commented 3 years ago

what can i do to have this not stale ? :)

SMillerDev commented 3 years ago

Get someone to look into it.

marco44 commented 3 years ago

I found the error, sorry I got a bit shy while looking at this bug initially, I was afraid I'd have to dig into doctrine… It's this RSS: https://mikrotik.com/current.rss, other RSS work.

It starts like this:

<?xml version="1.0" encoding="UTF-8" ?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><language>en-us</language><title>MikroTik Current</title><link>https://mikrotik.com/</link><atom:link href="//mikrotik.com/current.rss" rel="self" type="application/rss+xml" /><copyright>Copyright 2021, Mikrotikls Ltd</copyright><generator>MikroTik Rss</generator><ttl>60</ttl><description>Feed for newest RouterOS updates.</description><item><title>RouterOS 6.48.3 [Stable]</title><link>https://mikrotik.com/download/changelogs/stable</link><description><![CDATA[ <p><h3>6.48.3 changelog:</h3>MAJOR CHANGES IN v6.48.3:<br />

I don't really know why (I don't know the RSS spec that much), but it takes //mikrotik.com/current.rss as the url (see the SQL error message), which, if I understand this correctly:

    public function setUrl(string $url): Feed
    {
        $url = trim($url);
        if (strpos($url, 'http') === 0 && $this->url !== $url) {
            $this->url = $url;
            $this->setUrlHash(md5($url));
            $this->markFieldUpdated('url');
        }

        return $this;
    }

doesn't trigger the hash computation, as it doesn't start with http. I don't know if the RSS itself is wrong, but anyway that shouldn't trigger this kind of crash, I think.

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

adarnimrod commented 2 years ago

I get the same error, although in my case the URL is https://linux-system-roles.github.io/atom.xml . I'm using Nextcloud 23.0.1 from Docker Hub, MariaDB 10 and News 17.0.1. I can generate the system report and post the link if it helps.

marco44 commented 2 years ago

Oh, by the way, for these feeds, unchecking "auto discover feed" seems to be a workaround

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

z3ntu commented 2 years ago

I believe the feed https://explosm.net/rss.xml is also affected from this issue, but unchecking "Auto discover Feed" indeed works around the issue.

AccaliaDeElementia commented 2 years ago

this should be resolved by https://github.com/alexdebril/feed-io/pull/405 once accepted and pulled into Nextcloud News.

until then, disabling the discovery feature for affected feeds should allow the feeds to be added successfully.

Grotax commented 2 years ago

I also changed the behaviour of news to only use discover if the provided url doesn't already contain a feed.