dagu icon indicating copy to clipboard operation
dagu copied to clipboard

too long dag description causes scoket error

Open altmvogi opened this issue 1 year ago • 2 comments

when teh description of one dag is too long, the dag is not start and the error in std_out looks like this.

sample: "Rapid7_insightVM_rapid7_insightvm_copy_data_to_tenable_tables" error: 2023/03/08 03:37:39 failed to start socket server listen unix /tmp/@dagu-Rapid7_insightVM_rapid7_insightvm_copy_data_to_tenable_tables-d8e3ed564c22705f7e2958adbeeb3eb5.sock: bind: invalid argument

locks like for a socket server name there is a length restriction. i would try to figure out the maximum length and do not allow input on the WEB UI larger than the maximum field length.

regards Michael

altmvogi avatar Mar 08 '23 12:03 altmvogi

Same thing. I've set long and descriptive name for a DAG and it stopped working. It looks like a path to a Unix socket cannot be more than 108 bytes long.

User-26 avatar Jan 28 '24 10:01 User-26

Thanks a lot for reporting the issue. I think we can fix this logic to avoid the max length error. https://github.com/dagu-dev/dagu/blob/69515e19a7ae612fe66ff935862b7af1994092a8/internal/dag/dag.go#L74-L81

yohamta avatar Jan 28 '24 10:01 yohamta

I hit this today with a verbose description of the task too :).

@yohamta, I'm happy to contribute to fixing it and want to understand if you have preferences on implementation.

My first approach would be to simplify the socket by making it only use the md5 so it avoids the irregularities that occur if we truncate the name and append an md5.

like so

fmt.Sprintf("@dagu-%x.sock", bs)

But I wonder if you want a fragment of task name in there for human simplicity in debug cases? If so, I recommend keeping the first N-characters of the task name such that it always stays within the limit of socket lengths, eg:

pseudocode

`@dagu-${truncate(taskName)}-MD5.sock`

Such that it's always < 108 bytes.

Do you have a preference between those two implementations? The first seems less brittle but the second seems a little more user friendly during debug.

zph avatar Jun 26 '24 17:06 zph

Ok, pushed up the @dagu-${truncate(taskName)}-MD5.sock approach for review and added tests.

zph avatar Jun 26 '24 19:06 zph