Flow run Script not triggered with automated tagging

Support intro

Hey there I was trying to automate overlaying a PDF with another file if it was placed in a special folder. Therefore I have created a bash script which should be triggered if a new File is created and has a special tag.

Seems like the condition is met but only if the Tag is modified manually or the file is modified manually my script gets executed.

Nextcloud version (eg, 20.0.5): 26.0.1
Operating system and version (eg, Ubuntu 20.04): Ubuntu 22.04
Apache or nginx version (eg, Apache 2.4.25): Apache 2.4.52
PHP version (eg, 7.4): 8.0

The issue you are facing:

Is this the first time you’ve seen this error? (Y/N): N

Steps to replicate it:

  1. Upload file to directory
  2. Use automated tagging to tag all PDF Files in a specific directory (this works as expected)
  3. Use Workflow Script to run a bash script if a file was created and tagged with this tag (from 1)

The script I try to execute is located under /usr/local/bin/ and owned by www-data. The executable flag was set using sudo chmod +x /usr/local/bin/pdf_overlay.sh.

This is the script:

#!/bin/bash
exec 2>> /var/log/nextcloud/pdf_overlay.log
set -x

nextcloudpath=PathToNextcloudDataDirectory
filepath=$nextcloudpath$1
overlay=$nextcloudpath$2/files/flow/overlay.pdf
outputpath=/tmp/pdftk/
filename=$(basename "$filepath")
mkdir -p "$outputpath"

pdftk "$filepath" background "$overlay" output "$outputpath$filename"
mv "$outputpath$filename" "$filepath"

php /var/www/nextcloud/occ files:scan --path="$filepath" &> /dev/null

This is how I configured the flow:

I would expect the flow to be triggered every time a File was uploaded and tagged by automated tagging.
If I remove the tag manually and readd it everything works just fine.

This is the activity Tab of the uploaded file:

The output of your Nextcloud log in Admin > Logging:
This is the only part regarding workflow scripts

{
  "reqId": "kXqJxXjVXiJ8Yc9YMnAB",
  "level": 0,
  "time": "2023-06-14T09:41:43+00:00",
  "remoteAddr": "externalIP",
  "user": "Lukas",
  "app": "workflowengine",
  "method": "POST",
  "url": "/remote.php/dav/bulk",
  "message": "Cannot handle event \\OCP\\Files::postCreate of OC\\EventDispatcher\\GenericEventWrapper against entity OCA\\WorkflowEngine\\Entity\\File and operation OCA\\WorkflowScript\\Operation",
  "userAgent": "Mozilla/5.0 (Linux) mirall/3.7.3git (Nextcloud, ubuntu-6.2.0-20-generic ClientArchitecture: x86_64 OsArchitecture: x86_64)",
  "version": "26.0.1.1",
  "data": {
    "app": "workflowengine"
  }
}

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

<?php
$CONFIG = array (
  'instanceid' => '',
  'passwordsalt' => '',
  'secret' => '',
  'trusted_domains' => 
  array (
    0 => '',
    1 => '',
    2 => '',
  ),
  'trusted_proxies' => 
  array (
    0 => '',
    1 => '127.0.0.1',
    2 => '::1',
    3 => '',
  ),
  'datadirectory' => '',
  'overwrite.cli.url' => '',
  'overwriteprotocol' => 'https',
  'htaccess.RewriteBase' => '/',
  'dbtype' => 'mysql',
  'version' => '26.0.1.1',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'nextcloud',
  'dbpassword' => '',
  'logtimezone' => 'UTC',
  'force_language' => 'de',
  'default_phone_region' => 'DE',
  'installed' => true,
  'maintenance' => false,
  'memcache.local' => '\\OC\\Memcache\\Redis',
  'memcache.distributed' => '\\OC\\Memcache\\Redis',
  'filelocking.enabled' => 'true',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' => 
  array (
    'host' => '127.0.0.1',
    'port' => '6379',
    'password' => '',
    'timeout' => 0.0,
  ),
  'theme' => '',
  'loglevel' => 0,
  'mail_smtpmode' => 'smtp',
  'mail_from_address' => '',
  'mail_domain' => '',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_smtpauth' => 1,
  'mail_smtpsecure' => 'tls',
  'mail_smtphost' => '',
  'mail_smtpport' => '',
  'mail_smtpname' => '',
  'mail_smtppassword' => '',
  'filesystem_check_changes' => 1,
  'updater.release.channel' => 'stable',
  'trashbin_retention_obligation' => 30,
  'mysql.utf8mb4' => true,
  'app_install_overwrite' => 
  array (
    0 => 'keeweb',
    1 => 'carnet',
    2 => 'breezedark',
  ),
  'has_rebuilt_cache' => true,
  'preview_max_x' => '2048',
  'preview_max_y' => '2048',
  'jpeg_quality' => '60',
  'enforce_theme' => '',
);

The output of your Apache/nginx/system log in /var/log/____:
No errors logged.

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.

No errors logged

Hi Lukaz,
I have almost the same usecase and I stuck at the same problem.

Do you have an solution?
Greets Thorsten

I think it may be because your Run Script rule “When” it set to “File is created”. At creation time, the automated tag won’t yet be set to match on.

Does it make a difference if set the “When” to “File is accessed”?

I think, you are on aright way. But I don’t want to run my script every time someone accesses my file. This script should just be run once.

But anyway I will give your proposal a try,

BR Thorsten

Wouldn’t it be even better (and more logical) to trigger the script “When Tag assigned”

image

German: “Wenn Schlagwort zugewiesen”

image

That would trigger the script once, as soon as the tag is assigned by automated tagging.

Hope this helps.

Much luck!

Hi jtr,

I used if tag is assigned and also all other settings because you can multi select. I assume a logical or for those selections. None of them fired the trigger. In this case the trigger is an automatical Set keyword from file autotagging plugin. This does not work to fire my trigger. If I set the keyword manually, everything will work as expected.

Greets Thorsten

| ernolf
July 9 |

  • | - |

jtr:

Does it make a difference if set the “When” to “File is accessed”?

Wouldn’t it be even better (and more logical) to trigger the script “When Tag assigned”

German: “Wenn Schlagwort zugewiesen”

thorsten-schwartz:

I don’t want to run my script every time someone accesses my file. This script should just be run once.

That would trigger the script once, as soon as the tag is assigned by automated tagging.

Hope this helps.

Much luck!


Rufe das Thema auf oder antworte auf diese E-Mail, um zu antworten.

Um diese E-Mails abzubestellen, klicke hier.

Thorsten Schwartz

Tannenstraße 1
93346 Ihrlerstein
Deutschland

Email thorsten@schwartz-ihrlerstein.de
Telefon +49 9441 1744147
Fax +49 9441 7032545
Mobil +49 1512 2851639

keyserver https://keyserver.ubuntu.com/
key-ID 0xCDD06CFA6CDFED96
fingerprint FA03 CF9C A6BD 12CC 47F0 D9F0 CDD0 6CFA 6CDF ED96

Diese Email enthält vertrauliche und/oder rechtlich geschützte Informationen.
Wenn Sie nicht der richtige Adressat sind oder diese Email irrtümlich erhalten haben,
informieren Sie bitte sofort den Absender und vernichten Sie diese Email!

Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Email ist nicht gestattet!