Issue with forced share expiration in the morning here in New Zealand

Support intro

Sorry to hear you’re facing problems :slightly_frowning_face:

help.nextcloud.com is for home/non-enterprise users. If you’re running a business, paid support can be accessed via portal.nextcloud.com where we can ensure your business keeps running smoothly.

In order to help you as quickly as possible, before clicking Create Topic please provide as much of the below as you can. Feel free to use a pastebin service for logs, otherwise either indent short log examples with four spaces:

example

Or for longer, use three backticks above and below the code snippet:

longer
example
here

Some or all of the below information will be requested if it isn’t supplied; for fastest response please provide as much as you can :heart:

Nextcloud version (eg, 20.0.5): 25.0.6
Operating system and version (eg, Ubuntu 20.04): Ubuntu 20.04
Apache or nginx version (eg, Apache 2.4.25): Apache/2.4.41 (Ubuntu)
PHP version (eg, 7.4): PHP 7.4.3-4ubuntu2.18 (cli)

The issue you are facing:
We enforce an Expiration on shares (30 days). When a user goes to share a Folder/File they are getting an error message:
“Cannot set expiration date more than 30 days in the future”

We are located in New Zealand which is currently in NZ Standard Time (NZST) 12 hours ahead of UTC +1200

The issue is only happening in the morning our local time. There is no error if the share is created in the afternoon.

If the error appears the quick work around is using the calendar beside the Expiration Time (enforced) field and select the day one before the 30 days.

Is this the first time you’ve seen this error? (Y/N): Y Just upgraded to 25.0.6 from 24.0.12

Steps to replicate it:

  1. Click the share icon on a folder or file.
  2. Once the Password is shown click the Create button.
  3. Notification appears that password created and also the error message.
  4. Dialog stays until the new date is selected from calendar.

The output of your Nextcloud log in Admin > Logging:

PASTE HERE

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

<?php
$CONFIG = array (
  'passwordsalt' => 'xx',
  'secret' => 'xx',
  'trusted_domains' =>
  array (
    0 => 'xx',
  ),
  'datadirectory' => '/opt/nextcloud/data',
  'dbtype' => 'mysql',
  'version' => '25.0.6.1',
  'overwrite.cli.url' => 'https://xx/',
  'dbname' => 'xx',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc',
  'mysql.utf8mb4' => true,
  'dbuser' => 'xx',
  'dbpassword' => 'xx',
  'installed' => true,
  'memcache.local' => '\\OC\\Memcache\\Redis',
  'redis' =>
  array (
    'host' => 'localhost',
    'port' => xx,
  ),
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'proxy' => 'http://xx:xx',
  'knowledgebaseenabled' => false,
  'overwriteprotocol' => 'https',
  'overwitehost' => 'xx',
  'htaccess.RewriteBase' => '/',
  'maintenance' => false,
  'updater.release.channel' => 'stable',
  'skeletondirectory' => '',
  'log_type' => 'syslog',
  'syslog_tag' => 'nextcloud',
  'loglevel' => 0,
  'logtimezone' => 'Pacific/Auckland',
  'mail_smtpmode' => 'smtp',
  'mail_from_address' => 'xx',
  'mail_domain' => 'xx',
  'mail_smtphost' => 'xx',
  'mail_smtpport' => '25',
  'mail_smtpauthtype' => 'xx',
  'ldapIgnoreNamingRules' => false,
  'ldapProviderFactory' => '\\OCA\\User_LDAP\\LDAPProviderFactory',
  'ldapUserCleanupInterval' => '51',
  'instanceid' => 'xx',
  'lost_password_link' => 'disabled',
  'auth.webauthn.enabled' => false,
  'remember_login_cookie_lifetime' => xx,
  'session_lifetime' => xx,
  'session_keepalive' => true,
  'auto_logout' => true,
  'default_phone_region' => 'NZ',
  'profile.enabled' => false,
);

The output of your Apache/nginx/system log in /var/log/____:
Note 11:54 was the Error, 12:01 was shared OK

IP - - [20/May/2023:11:53:38 +1200] "GET /ocs/v2.php/apps/notifications/api/v2/notifications HTTP/1.1" 304 841 "-" "Mozilla/5.0 Browser ID"
IP - - [20/May/2023:11:54:08 +1200] "GET /ocs/v2.php/apps/notifications/api/v2/notifications HTTP/1.1" 304 841 "-" "Mozilla/5.0 Browser ID"
IP - - [20/May/2023:11:54:30 +1200] "PROPFIND /remote.php/dav/files/E9A8A786-3342-471A-A441-C27235F14437/test-2023-05-19b HTTP/1.1" 207 2248 "-" "Mozilla/5.0 Browser ID"
IP - - [20/May/2023:11:54:31 +1200] "GET /apps/files/ajax/getstoragestats?dir=%2Ftest-2023-05-19b HTTP/1.1" 200 1138 "-" "Mozilla/5.0 Browser ID"
IP - - [20/May/2023:11:54:32 +1200] "PROPFIND /remote.php/dav/files/E9A8A786-3342-471A-A441-C27235F14437//test-2023-05-19b HTTP/1.1" 207 1702 "-" "Mozilla/5.0 Browser ID"
IP - - [20/May/2023:11:54:32 +1200] "PROPFIND /remote.php/dav/systemtags-relations/files/92346 HTTP/1.1" 207 1274 "-" "Mozilla/5.0 Browser ID"
IP - - [20/May/2023:11:54:32 +1200] "PROPFIND /remote.php/dav/systemtags-relations/files/92346 HTTP/1.1" 207 1806 "-" "Mozilla/5.0 Browser ID"
IP - - [20/May/2023:11:54:32 +1200] "GET /ocs/v2.php/apps/activity/api/v2/activity/filter?format=json&object_type=files&object_id=92346 HTTP/1.1" 200 2079 "-" "Mozilla/5.0 Browser ID"
IP - - [20/May/2023:11:54:32 +1200] "GET /ocs/v2.php/apps/files_sharing/api/v1/shares?format=json&path=%2Ftest-2023-05-19b&shared_with_me=true HTTP/1.1" 200 1508 "-" "Mozilla/5.0 Browser ID"
IP - - [20/May/2023:11:54:32 +1200] "GET /ocs/v2.php/apps/related_resources/related/files/92346?format=json HTTP/1.1" 200 976 "-" "Mozilla/5.0 Browser ID"
IP - - [20/May/2023:11:54:32 +1200] "GET /apps/theming/img/core/filetypes/folder-public.svg?v=1f1f675a HTTP/1.1" 200 2674 "https://ServerURL/apps/files/?dir=/test-2023-05-19b&fileid=92346" "Mozilla/5.0 Browser ID"
IP - - [20/May/2023:11:54:32 +1200] "GET /ocs/v2.php/apps/files_sharing/api/v1/shares?format=json&path=%2Ftest-2023-05-19b&reshares=true HTTP/1.1" 200 2028 "-" "Mozilla/5.0 Browser ID"
IP - - [20/May/2023:11:54:32 +1200] "GET /ocs/v2.php/apps/files_sharing/api/v1/sharees_recommended?format=json&itemType=dir HTTP/1.1" 200 1020 "-" "Mozilla/5.0 Browser ID"
IP - - [20/May/2023:11:54:37 +1200] "DELETE /ocs/v2.php/apps/files_sharing/api/v1/shares/47 HTTP/1.1" 200 976 "-" "Mozilla/5.0 Browser ID"
IP - - [20/May/2023:11:54:38 +1200] "GET /ocs/v2.php/apps/notifications/api/v2/notifications HTTP/1.1" 304 309 "-" "Mozilla/5.0 Browser ID"
IP - - [20/May/2023:11:54:38 +1200] "GET /csrftoken HTTP/1.1" 200 1549 "-" "Mozilla/5.0 Browser ID"
IP - - [20/May/2023:11:54:53 +1200] "GET /ocs/v2.php/apps/password_policy/api/v1/generate HTTP/1.1" 200 1529 "-" "Mozilla/5.0 Browser ID"
IP - - [20/May/2023:11:54:53 +1200] "GET /ocs/v2.php/apps/password_policy/api/v1/generate HTTP/1.1" 200 997 "-" "Mozilla/5.0 Browser ID"
IP - - [20/May/2023:11:54:55 +1200] "GET /ocs/v2.php/apps/password_policy/api/v1/generate HTTP/1.1" 200 997 "-" "Mozilla/5.0 Browser ID"
IP - - [20/May/2023:11:54:55 +1200] "POST /ocs/v2.php/apps/files_sharing/api/v1/shares HTTP/1.1" 404 1013 "-" "Mozilla/5.0 Browser ID"
IP - - [20/May/2023:11:55:08 +1200] "GET /ocs/v2.php/apps/notifications/api/v2/notifications HTTP/1.1" 304 841 "-" "Mozilla/5.0 Browser ID"
IP - - [20/May/2023:11:55:38 +1200] "GET /ocs/v2.php/apps/notifications/api/v2/notifications HTTP/1.1" 304 841 "-" "Mozilla/5.0 Browser ID"
IP - - [20/May/2023:11:56:08 +1200] "GET /ocs/v2.php/apps/notifications/api/v2/notifications HTTP/1.1" 304 841 "-" "Mozilla/5.0 Browser ID"
IP - - [20/May/2023:11:56:38 +1200] "GET /ocs/v2.php/apps/notifications/api/v2/notifications HTTP/1.1" 304 841 "-" "Mozilla/5.0 Browser ID"
IP - - [20/May/2023:11:57:08 +1200] "GET /ocs/v2.php/apps/notifications/api/v2/notifications HTTP/1.1" 304 841 "-" "Mozilla/5.0 Browser ID"
IP - - [20/May/2023:11:57:29 +1200] "GET /ocs/v2.php/apps/password_policy/api/v1/generate HTTP/1.1" 200 1529 "-" "Mozilla/5.0 Browser ID"
IP - - [20/May/2023:11:57:30 +1200] "POST /ocs/v2.php/apps/files_sharing/api/v1/shares HTTP/1.1" 404 1013 "-" "Mozilla/5.0 Browser ID"
IP - - [20/May/2023:11:57:38 +1200] "GET /ocs/v2.php/apps/notifications/api/v2/notifications HTTP/1.1" 304 841 "-" "Mozilla/5.0 Browser ID"
IP - - [20/May/2023:11:57:39 +1200] "GET /apps/files/ajax/getstoragestats?dir=%2Ftest-2023-05-19b HTTP/1.1" 200 1138 "-" "Mozilla/5.0 Browser ID"
IP - - [20/May/2023:11:58:08 +1200] "GET /ocs/v2.php/apps/notifications/api/v2/notifications HTTP/1.1" 304 841 "-" "Mozilla/5.0 Browser ID"
IP - - [20/May/2023:11:58:38 +1200] "GET /ocs/v2.php/apps/notifications/api/v2/notifications HTTP/1.1" 304 841 "-" "Mozilla/5.0 Browser ID"
IP - - [20/May/2023:11:59:08 +1200] "GET /ocs/v2.php/apps/notifications/api/v2/notifications HTTP/1.1" 304 841 "-" "Mozilla/5.0 Browser ID"
IP - - [20/May/2023:11:59:38 +1200] "GET /ocs/v2.php/apps/notifications/api/v2/notifications HTTP/1.1" 304 841 "-" "Mozilla/5.0 Browser ID"
IP - - [20/May/2023:12:00:08 +1200] "GET /ocs/v2.php/apps/notifications/api/v2/notifications HTTP/1.1" 304 841 "-" "Mozilla/5.0 Browser ID"
IP - - [20/May/2023:12:00:38 +1200] "GET /ocs/v2.php/apps/notifications/api/v2/notifications HTTP/1.1" 304 841 "-" "Mozilla/5.0 Browser ID"
IP - - [20/May/2023:12:01:08 +1200] "GET /ocs/v2.php/apps/notifications/api/v2/notifications HTTP/1.1" 304 841 "-" "Mozilla/5.0 Browser ID"
IP - - [20/May/2023:12:01:10 +1200] "PROPFIND /remote.php/dav/files/E9A8A786-3342-471A-A441-C27235F14437/test-2023-05-19b HTTP/1.1" 207 1702 "-" "Mozilla/5.0 Browser ID"
IP - - [20/May/2023:12:01:10 +1200] "GET /apps/files/ajax/getstoragestats?dir=%2Ftest-2023-05-19b HTTP/1.1" 200 1138 "-" "Mozilla/5.0 Browser ID"
IP - - [20/May/2023:12:01:15 +1200] "PROPFIND /remote.php/dav/files/E9A8A786-3342-471A-A441-C27235F14437//test-2023-05-19b HTTP/1.1" 207 1687 "-" "Mozilla/5.0 Browser ID"
IP - - [20/May/2023:12:01:15 +1200] "PROPFIND /remote.php/dav/systemtags-relations/files/92346 HTTP/1.1" 207 1274 "-" "Mozilla/5.0 Browser ID"
IP - - [20/May/2023:12:01:15 +1200] "PROPFIND /remote.php/dav/systemtags-relations/files/92346 HTTP/1.1" 207 1806 "-" "Mozilla/5.0 Browser ID"
IP - - [20/May/2023:12:01:15 +1200] "GET /ocs/v2.php/apps/related_resources/related/files/92346?format=json HTTP/1.1" 200 6291 "-" "Mozilla/5.0 Browser ID"
IP - - [20/May/2023:12:01:15 +1200] "GET /ocs/v2.php/apps/files_sharing/api/v1/shares?format=json&path=%2Ftest-2023-05-19b&reshares=true HTTP/1.1" 200 1508 "-" "Mozilla/5.0 Browser ID"
IP - - [20/May/2023:12:01:15 +1200] "GET /ocs/v2.php/apps/files_sharing/api/v1/shares?format=json&path=%2Ftest-2023-05-19b&shared_with_me=true HTTP/1.1" 200 1508 "-" "Mozilla/5.0 Browser ID"
IP - - [20/May/2023:12:01:15 +1200] "GET /ocs/v2.php/apps/activity/api/v2/activity/filter?format=json&object_type=files&object_id=92346 HTTP/1.1" 200 2104 "-" "Mozilla/5.0 Browser ID"
IP - - [20/May/2023:12:01:15 +1200] "GET /ocs/v2.php/apps/files_sharing/api/v1/sharees_recommended?format=json&itemType=dir HTTP/1.1" 200 1020 "-" "Mozilla/5.0 Browser ID"
IP - - [20/May/2023:12:01:29 +1200] "GET /ocs/v2.php/apps/password_policy/api/v1/generate HTTP/1.1" 200 1529 "-" "Mozilla/5.0 Browser ID"
IP - - [20/May/2023:12:01:29 +1200] "GET /ocs/v2.php/apps/password_policy/api/v1/generate HTTP/1.1" 200 997 "-" "Mozilla/5.0 Browser ID"
IP - - [20/May/2023:12:01:38 +1200] "GET /ocs/v2.php/apps/notifications/api/v2/notifications HTTP/1.1" 304 841 "-" "Mozilla/5.0 Browser ID"
IP - - [20/May/2023:12:01:43 +1200] "GET /ocs/v2.php/apps/password_policy/api/v1/generate HTTP/1.1" 200 997 "-" "Mozilla/5.0 Browser ID"
IP - - [20/May/2023:12:01:43 +1200] "POST /ocs/v2.php/apps/files_sharing/api/v1/shares HTTP/1.1" 200 1492 "-" "Mozilla/5.0 Browser ID"
IP - - [20/May/2023:12:02:08 +1200] "GET /ocs/v2.php/apps/notifications/api/v2/notifications HTTP/1.1" 304 841 "-" "Mozilla/5.0 Browser ID"
IP - - [20/May/2023:12:02:38 +1200] "GET /ocs/v2.php/apps/notifications/api/v2/notifications HTTP/1.1" 304 841 "-" "Mozilla/5.0 Browser ID"
IP - - [20/May/2023:12:02:39 +1200] "GET /apps/files/ajax/getstoragestats?dir=%2Ftest-2023-05-19b HTTP/1.1" 200 1138 "-" "Mozilla/5.0 Browser ID"

PHP /etc/php/7.4/apache2/php.ini relevant part

; Defines the default timezone used by the date functions
; http://php.net/date.timezone
;date.timezone =
date.timezone = "Pacific/Auckland"

Output errors in nextcloud.log in /var/www/ or as admin user in top right menu, filtering for errors. Use a pastebin service if necessary.

Note this is from TEST system where expiration is set to 5 days. Prod is 30 days.

"TimeGenerated [Local Time]",Computer,Facility,ProcessID,SyslogMessage
"5/20/2023, 11:59:16.826 AM","ServerURL",user,UserID,"{""reqId"":""3aFq5V8nR2lhGSEnywya"",""level"":3,""time"":""2023-05-20T11:57:30+12:00"",""remoteAddr"":""IP"",""user"":""UserUUID"",""app"":""no app in context"",""method"":""POST"",""url"":""/ocs/v2.php/apps/files_sharing/api/v1/shares"",""message"":""{\""Exception\"":\""OCP\\\\Share\\\\Exceptions\\\\GenericShareException\"",\""Message\"":\""Cannot set expiration date more than 5 days in the future\"",\""Code\"":404,\""Trace\"":[{\""file\"":\""/opt/nextcloud/nextcloud/lib/private/Share20/Manager.php\"",\""line\"":779,\""function\"":\""validateExpirationDateLink\"",\""class\"":\""OC\\\\Share20\\\\Manager\"",\""type\"":\""->\""},{\""file\"":\""/opt/nextcloud/nextcloud/apps/files_sharing/lib/Controller/ShareAPIController.php\"",\""line\"":715,\""function\"":\""createShare\"",\""class\"":\""OC\\\\Share20\\\\Manager\"",\""type\"":\""->\""},{\""file\"":\""/opt/nextcloud/nextcloud/lib/private/AppFramework/Http/Dispatcher.php\"",\""line\"":225,\""function\"":\""createShare\"",\""class\"":\""OCA\\\\Files_Sharing\\\\Controller\\\\ShareAPIController\"",\""type\"":\""->\""},{\""file\"":\""/opt/nextcloud/nextcloud/lib/private/AppFramework/Http/Dispatcher.php\"",\""line\"":133,\""function\"":\""executeController\"",\""class\"":\""OC\\\\AppFramework\\\\Http\\\\Dispatcher\"",\""type\"":\""->\""},{\""file\"":\""/opt/nextcloud/nextcloud/lib/private/AppFramework/App.php\"",\""line\"":172,\""function\"":\""dispatch\"",\""class\"":\""OC\\\\AppFramework\\\\Http\\\\Dispatcher\"",\""type\"":\""->\""},{\""file\"":\""/opt/nextcloud/nextcloud/lib/private/Route/Router.php\"",\""line\"":298,\""function\"":\""main\"",\""class\"":\""OC\\\\AppFramework\\\\App\"",\""type\"":\""::\""},{\""file\"":\""/opt/nextcloud/nextcloud/ocs/v1.php\"",\""line\"":64,\""function\"":\""match\"",\""class\"":\""OC\\\\Route\\\\Router\"",\""type\"":\""->\""},{\""file\"":\""/opt/nextcloud/nextcloud/ocs/v2.php\"",\""line\"":23,\""args\"":[\""/opt/nextcloud/nextcloud/ocs/v1.php\""],\""function\"":\""require_once\""}],\""File\"":\""/opt/nextcloud/nextcloud/lib/private/Share20/Manager.php\"",\""Line\"":516,\""Hint\"":\""Cannot set expiration date more than 5 days in the future\"",\""CustomMessage\"":\""--\""}"",""userAgent"":""Mozilla/5.0 BrowserID"",""version"":""25.0.6.1""}"
"5/20/2023, 11:54:55.635 AM","ServerURL",user,UserID2,"{""reqId"":""KY4MoNDYNZZMo5GIyQXM"",""level"":3,""time"":""2023-05-20T11:54:55+12:00"",""remoteAddr"":""IP"",""user"":""UserUUID"",""app"":""no app in context"",""method"":""POST"",""url"":""/ocs/v2.php/apps/files_sharing/api/v1/shares"",""message"":""{\""Exception\"":\""OCP\\\\Share\\\\Exceptions\\\\GenericShareException\"",\""Message\"":\""Cannot set expiration date more than 5 days in the future\"",\""Code\"":404,\""Trace\"":[{\""file\"":\""/opt/nextcloud/nextcloud/lib/private/Share20/Manager.php\"",\""line\"":779,\""function\"":\""validateExpirationDateLink\"",\""class\"":\""OC\\\\Share20\\\\Manager\"",\""type\"":\""->\""},{\""file\"":\""/opt/nextcloud/nextcloud/apps/files_sharing/lib/Controller/ShareAPIController.php\"",\""line\"":715,\""function\"":\""createShare\"",\""class\"":\""OC\\\\Share20\\\\Manager\"",\""type\"":\""->\""},{\""file\"":\""/opt/nextcloud/nextcloud/lib/private/AppFramework/Http/Dispatcher.php\"",\""line\"":225,\""function\"":\""createShare\"",\""class\"":\""OCA\\\\Files_Sharing\\\\Controller\\\\ShareAPIController\"",\""type\"":\""->\""},{\""file\"":\""/opt/nextcloud/nextcloud/lib/private/AppFramework/Http/Dispatcher.php\"",\""line\"":133,\""function\"":\""executeController\"",\""class\"":\""OC\\\\AppFramework\\\\Http\\\\Dispatcher\"",\""type\"":\""->\""},{\""file\"":\""/opt/nextcloud/nextcloud/lib/private/AppFramework/App.php\"",\""line\"":172,\""function\"":\""dispatch\"",\""class\"":\""OC\\\\AppFramework\\\\Http\\\\Dispatcher\"",\""type\"":\""->\""},{\""file\"":\""/opt/nextcloud/nextcloud/lib/private/Route/Router.php\"",\""line\"":298,\""function\"":\""main\"",\""class\"":\""OC\\\\AppFramework\\\\App\"",\""type\"":\""::\""},{\""file\"":\""/opt/nextcloud/nextcloud/ocs/v1.php\"",\""line\"":64,\""function\"":\""match\"",\""class\"":\""OC\\\\Route\\\\Router\"",\""type\"":\""->\""},{\""file\"":\""/opt/nextcloud/nextcloud/ocs/v2.php\"",\""line\"":23,\""args\"":[\""/opt/nextcloud/nextcloud/ocs/v1.php\""],\""function\"":\""require_once\""}],\""File\"":\""/opt/nextcloud/nextcloud/lib/private/Share20/Manager.php\"",\""Line\"":516,\""Hint\"":\""Cannot set expiration date more than 5 days in the future\"",\""CustomMessage\"":\""--\""}"",""userAgent"":""Mozilla/5.0 BrowserID"",""version"":""25.0.6.1""}"
"5/20/2023, 11:51:39.612 AM","ServerURL",user,676650,"{""reqId"":""krhptR4yhitCRrT5IT1h"",""level"":3,""time"":""2023-05-20T11:50:57+12:00"",""remoteAddr"":""IP"",""user"":""UserUUID"",""app"":""no app in context"",""method"":""POST"",""url"":""/ocs/v2.php/apps/files_sharing/api/v1/shares"",""message"":""{\""Exception\"":\""OCP\\\\Share\\\\Exceptions\\\\GenericShareException\"",\""Message\"":\""Cannot set expiration date more than 5 days in the future\"",\""Code\"":404,\""Trace\"":[{\""file\"":\""/opt/nextcloud/nextcloud/lib/private/Share20/Manager.php\"",\""line\"":779,\""function\"":\""validateExpirationDateLink\"",\""class\"":\""OC\\\\Share20\\\\Manager\"",\""type\"":\""->\""},{\""file\"":\""/opt/nextcloud/nextcloud/apps/files_sharing/lib/Controller/ShareAPIController.php\"",\""line\"":715,\""function\"":\""createShare\"",\""class\"":\""OC\\\\Share20\\\\Manager\"",\""type\"":\""->\""},{\""file\"":\""/opt/nextcloud/nextcloud/lib/private/AppFramework/Http/Dispatcher.php\"",\""line\"":225,\""function\"":\""createShare\"",\""class\"":\""OCA\\\\Files_Sharing\\\\Controller\\\\ShareAPIController\"",\""type\"":\""->\""},{\""file\"":\""/opt/nextcloud/nextcloud/lib/private/AppFramework/Http/Dispatcher.php\"",\""line\"":133,\""function\"":\""executeController\"",\""class\"":\""OC\\\\AppFramework\\\\Http\\\\Dispatcher\"",\""type\"":\""->\""},{\""file\"":\""/opt/nextcloud/nextcloud/lib/private/AppFramework/App.php\"",\""line\"":172,\""function\"":\""dispatch\"",\""class\"":\""OC\\\\AppFramework\\\\Http\\\\Dispatcher\"",\""type\"":\""->\""},{\""file\"":\""/opt/nextcloud/nextcloud/lib/private/Route/Router.php\"",\""line\"":298,\""function\"":\""main\"",\""class\"":\""OC\\\\AppFramework\\\\App\"",\""type\"":\""::\""},{\""file\"":\""/opt/nextcloud/nextcloud/ocs/v1.php\"",\""line\"":64,\""function\"":\""match\"",\""class\"":\""OC\\\\Route\\\\Router\"",\""type\"":\""->\""},{\""file\"":\""/opt/nextcloud/nextcloud/ocs/v2.php\"",\""line\"":23,\""args\"":[\""/opt/nextcloud/nextcloud/ocs/v1.php\""],\""function\"":\""require_once\""}],\""File\"":\""/opt/nextcloud/nextcloud/lib/private/Share20/Manager.php\"",\""Line\"":516,\""Hint\"":\""Cannot set expiration date more than 5 days in the future\"",\""CustomMessage\"":\""--\""}"",""userAgent"":""Mozilla/5.0 BrowserID"",""version"":""25.0.6.1""}"
"5/20/2023, 11:43:58.821 AM","ServerURL",user,676674,"{""reqId"":""ANel4bIAvDd2iZhFBdEz"",""level"":3,""time"":""2023-05-20T11:43:31+12:00"",""remoteAddr"":""IP"",""user"":""UserUUID"",""app"":""no app in context"",""method"":""POST"",""url"":""/ocs/v2.php/apps/files_sharing/api/v1/shares"",""message"":""{\""Exception\"":\""OCP\\\\Share\\\\Exceptions\\\\GenericShareException\"",\""Message\"":\""Cannot set expiration date more than 5 days in the future\"",\""Code\"":404,\""Trace\"":[{\""file\"":\""/opt/nextcloud/nextcloud/lib/private/Share20/Manager.php\"",\""line\"":779,\""function\"":\""validateExpirationDateLink\"",\""class\"":\""OC\\\\Share20\\\\Manager\"",\""type\"":\""->\""},{\""file\"":\""/opt/nextcloud/nextcloud/apps/files_sharing/lib/Controller/ShareAPIController.php\"",\""line\"":715,\""function\"":\""createShare\"",\""class\"":\""OC\\\\Share20\\\\Manager\"",\""type\"":\""->\""},{\""file\"":\""/opt/nextcloud/nextcloud/lib/private/AppFramework/Http/Dispatcher.php\"",\""line\"":225,\""function\"":\""createShare\"",\""class\"":\""OCA\\\\Files_Sharing\\\\Controller\\\\ShareAPIController\"",\""type\"":\""->\""},{\""file\"":\""/opt/nextcloud/nextcloud/lib/private/AppFramework/Http/Dispatcher.php\"",\""line\"":133,\""function\"":\""executeController\"",\""class\"":\""OC\\\\AppFramework\\\\Http\\\\Dispatcher\"",\""type\"":\""->\""},{\""file\"":\""/opt/nextcloud/nextcloud/lib/private/AppFramework/App.php\"",\""line\"":172,\""function\"":\""dispatch\"",\""class\"":\""OC\\\\AppFramework\\\\Http\\\\Dispatcher\"",\""type\"":\""->\""},{\""file\"":\""/opt/nextcloud/nextcloud/lib/private/Route/Router.php\"",\""line\"":298,\""function\"":\""main\"",\""class\"":\""OC\\\\AppFramework\\\\App\"",\""type\"":\""::\""},{\""file\"":\""/opt/nextcloud/nextcloud/ocs/v1.php\"",\""line\"":64,\""function\"":\""match\"",\""class\"":\""OC\\\\Route\\\\Router\"",\""type\"":\""->\""},{\""file\"":\""/opt/nextcloud/nextcloud/ocs/v2.php\"",\""line\"":23,\""args\"":[\""/opt/nextcloud/nextcloud/ocs/v1.php\""],\""function\"":\""require_once\""}],\""File\"":\""/opt/nextcloud/nextcloud/lib/private/Share20/Manager.php\"",\""Line\"":516,\""Hint\"":\""Cannot set expiration date more than 5 days in the future\"",\""CustomMessage\"":\""--\""}"",""userAgent"":""Mozilla/5.0 BrowserID"",""version"":""25.0.6.1""}"
"5/20/2023, 11:43:58.810 AM","ServerURL",user,676674,"{""reqId"":""aUQo0n2q6Q9DpLENM247"",""level"":3,""time"":""2023-05-20T11:43:26+12:00"",""remoteAddr"":""IP"",""user"":""UserUUID"",""app"":""no app in context"",""method"":""POST"",""url"":""/ocs/v2.php/apps/files_sharing/api/v1/shares"",""message"":""{\""Exception\"":\""OCP\\\\Share\\\\Exceptions\\\\GenericShareException\"",\""Message\"":\""Cannot set expiration date more than 5 days in the future\"",\""Code\"":404,\""Trace\"":[{\""file\"":\""/opt/nextcloud/nextcloud/lib/private/Share20/Manager.php\"",\""line\"":779,\""function\"":\""validateExpirationDateLink\"",\""class\"":\""OC\\\\Share20\\\\Manager\"",\""type\"":\""->\""},{\""file\"":\""/opt/nextcloud/nextcloud/apps/files_sharing/lib/Controller/ShareAPIController.php\"",\""line\"":715,\""function\"":\""createShare\"",\""class\"":\""OC\\\\Share20\\\\Manager\"",\""type\"":\""->\""},{\""file\"":\""/opt/nextcloud/nextcloud/lib/private/AppFramework/Http/Dispatcher.php\"",\""line\"":225,\""function\"":\""createShare\"",\""class\"":\""OCA\\\\Files_Sharing\\\\Controller\\\\ShareAPIController\"",\""type\"":\""->\""},{\""file\"":\""/opt/nextcloud/nextcloud/lib/private/AppFramework/Http/Dispatcher.php\"",\""line\"":133,\""function\"":\""executeController\"",\""class\"":\""OC\\\\AppFramework\\\\Http\\\\Dispatcher\"",\""type\"":\""->\""},{\""file\"":\""/opt/nextcloud/nextcloud/lib/private/AppFramework/App.php\"",\""line\"":172,\""function\"":\""dispatch\"",\""class\"":\""OC\\\\AppFramework\\\\Http\\\\Dispatcher\"",\""type\"":\""->\""},{\""file\"":\""/opt/nextcloud/nextcloud/lib/private/Route/Router.php\"",\""line\"":298,\""function\"":\""main\"",\""class\"":\""OC\\\\AppFramework\\\\App\"",\""type\"":\""::\""},{\""file\"":\""/opt/nextcloud/nextcloud/ocs/v1.php\"",\""line\"":64,\""function\"":\""match\"",\""class\"":\""OC\\\\Route\\\\Router\"",\""type\"":\""->\""},{\""file\"":\""/opt/nextcloud/nextcloud/ocs/v2.php\"",\""line\"":23,\""args\"":[\""/opt/nextcloud/nextcloud/ocs/v1.php\""],\""function\"":\""require_once\""}],\""File\"":\""/opt/nextcloud/nextcloud/lib/private/Share20/Manager.php\"",\""Line\"":516,\""Hint\"":\""Cannot set expiration date more than 5 days in the future\"",\""CustomMessage\"":\""--\""}"",""userAgent"":""Mozilla/5.0 BrowserID"",""version"":""25.0.6.1""}"

I wonder if perhaps your server OS time is configured in UTC while everything else you’re doing is local time and this is causing an unexpected interaction.

Interesting that it sounds like you didn’t experience this in prior versions. Is that correct?

In the mean time you may be able to workaround the issue by also setting the default via occ to just below the 30 hard limit:

https://docs.nextcloud.com/server/25/admin_manual/configuration_files/file_sharing_configuration.html#distinguish-between-max-expiration-date-and-default-expiration-date

jtr

Cheers for that. First we do set server to local time. I meant to include a snippet of that but posted before including :frowning:

$ date
Sun 21 May 2023 10:34:40 AM NZST

So its not that.

I tried to share a folder again this morning and its failed again, so it is not a one off.

This is the first time I have seen this, so this has been working on all previous versions we have had on the server.

Because there is a sort of stack trace in the nextcloud.log message I did some digging into the code. I am not a php programmer, BASH or Perl are my go tos, But I can see where they take todays date, strip out the hours,min,sec making it midnight. Then comparing it to what I assume is a date picked up from the setting you put in the Admin Console.

The code snippet that does the compare, with my comments :

// If we enforce the expiration date check that is does not exceed
                if ($this->shareApiLinkDefaultExpireDateEnforced()) {
                        if ($expirationDate === null) {
                                throw new \InvalidArgumentException('Expiration date is enforced');
                        }
//JP007 - we are enforcing

                        $date = new \DateTime();  //JP007 Get current date&Time eg. 20/05/2023:09:05:00
                        $date->setTime(0, 0, 0);  //JP007 Set the current date&time to Midnight eg. 20/5/2023:00:00:00
                        $date->add(new \DateInterval('P' . $this->shareApiLinkDefaultExpireDays() . 'D')); // JP007 Add the P??D to the 20/5/2023:00:00:00  
                        if ($date < $expirationDate) {    //JP007 so if 20/5/2023:00:00:00+DateInterval is less then ExpirationDate send error message
                                $message = $this->l->n('Cannot set expiration date more than %n day in the future', 'Cannot set expiration date more than %n days in the future', $this->shareApiLinkDefaultExpireDays());
                                throw new GenericShareException($message, $message, 404);
                        }
                }

As I said, not a PHP programmer so need to follow where $expirationDate is coming from and not 100% sure what the “$date->add(new \DateInterval” bit is doing.

I am guessing its using a non time zone adjusted time to calculate $expirationDate. Then taking current time, setting it to midnight here before comparing and that’s why we are getting the issue only happening in the morning here. I need to dig deeper.

Note that I did a diff between the older version of code in this file /opt/nextcloud/nextcloud/lib/private/Share20/Manager.php and this snippet has not changed. So I am pretty sure it is the values of the variables coming in from else where that have started or stopped using time zone info.

I will check out the documentation you suggested and will do some more digging…

Again thanks for the heads up.

Cheers
Jim

Just an additional note on versions this is happening in.
I have some additional TEST/DEV instances and I can confirm this is happening in version 25.0.3 as well.
The version 24.0.x it is NOT happening.

Edit…
I have just tried the suggested setting the defaults lower than the forced expiration dates and this HAS NOT worked. Back to code reviewing… :slight_smile:

JP007

I have done some deep diving into the code.

Have run a diff over the old code (24.0.12) vs the new code (25.0.6) and have not found anything that looks changed around the Expiration date gathering/comparisons area.

I am thinking that the setting of the Hour,Min,Sec to 0’s and New Zealand being in Standard Time at the moment UTC+1200 that when the comparison comes along its tripping over this.

As an experiment (and have to wait until tomorrow morning to test) I have the ability to change a test system to Australia/Sydney time zone to see if that makes a difference.

JP007

Just to finish off. I tested the server I “moved” to Sydney and the issue did not happen.

I have opened a bug report #38405 as I got to the end of my PHP Object Orientated piece of string on this.

JP007

having same issue in Sydney ,with enforced date users get error as long as UTC date is not same as ours with is till 11am atm, Have you found any solution /fix yet ?
Time on server is AU/Sydney but still getting the same error