apoc.custom.declareProcedure always throws exception ./. corresponding cypher code works

I'm trying to create procedure for a cypher script with apoc.custom.declareProcedure (same for the asProcedure pendant) and always receive the exception:
Failed to invoke procedure `apoc.custom.declareProcedure`: Caused by: java.lang.RuntimeException: Query results do not match requested output.
Here's my procedure: procedure.txt
And a corresponding cypher script cypher.txt, which works like a charm
I've also tried to change the output type to NODE? or ANY but nothing worked.
Can anybody have a look at it and help me out?

Kind regards,
Marc

@marc.roth

This is definitely a bug.
I still don't understand in which cases,
but with some queries like yours,
the "EXPLAIN customQuery" executed under the hood to verify the query,
returns log@<NUMBER> as a column, instead of log, this cause the error.
I opened an issue for it, The apoc.custom.declareProcedure throws exception "Query results do not match requested output" with some queries · Issue #2605 · neo4j-contrib/neo4j-apoc-procedures · GitHub

Ok, perhaps I got it.
The bug happens because your query use the variable log twice,
so the "EXPLAIN query" return log with an id to distinguish it from the other.

As a temporary workaround, you could modify your query changing the final part
from match (node)-[:has]->(log:System:Log) where (node)-[:current]->(log) return log
to match (node)-[:has]->(logAnother:System:Log) where (node)-[:current]->(logAnother) return logAnother
and the return output from (log::NODE) to (logAnother::NODE)