jonasthewolf / gsn2x

Tool to create graphical representations of Goal Structuring Notations from YAML.
MIT License
26 stars 9 forks source link

Potential bug: thread 'main' panicked at src/dirgraph/mod.rs:410:18: #433

Closed ecleipteon closed 2 months ago

ecleipteon commented 2 months ago

Hi,

Thanks for all your hard work and effort in developing gsn2x. I have recently started using it and I am finding it brilliant. While experimenting with the rendering, I managed to crash the program. I am not sure whether it is my fault or an actual bug. Either way, I thought it was worth reporting

Describe the bug

During the rendering, I got this message

me@laptop gsn-template % ../../../GSN/gsn2x/target/release/gsn2x -a arch.svg -f full.svg -o out2 index.anon.gsn.yaml hazard.anon.gsn.yaml
Rendering "out2/hazard.anon.gsn.svg": OK
Rendering "out2/index.anon.gsn.svg": OK
Rendering "out2/arch.svg": OK
thread 'main' panicked at src/dirgraph/mod.rs:410:18:
called `Option::unwrap()` on a `None` value
note: run with `RUST_BACKTRACE=

To Reproduce

These are the two files to reproduce the bug

index.anon.gsn.yaml

module:
  name: MainClaim
  brief: This is the index.gsn.yaml file
#  uses: [hazard.anon.gsn.yaml]

G00001:
  text: |-
    Some text
  supportedBy: [S00001, S00002]
S00001:
  text: |-
    Some text
  supportedBy: [Sn00001]
  inContextOf: [J00001, A00001, C00001]
  # rankIncrement: 2
  horizontalIndex:
    relative: 0
S00002:
  text: |-
    Some text
  supportedBy: [G00002]
  horizontalIndex:
    relative: 1
G00002:
  text: |-
    Some text
  undeveloped: true
J00001:
  text: |-
    Some text
  horizontalIndex:
    relative: 1
A00001:
  text: |-
    Some text
  horizontalIndex:
    relative: -1
C00001:
  text: |-
    Some text
  horizontalIndex:
    relative: -1
Sn00001:
  text: Some text
  rankIncrement: 2
  horizontalIndex:
    relative: -1

hazards.anon.gsn.yaml


module:
  name: ClaimHazard
  brief: This is a template for any hazard
  #  uses: [uca.gsn.yaml]
  extends:
    - module: MainClaim
      develops:
        G00002: [G00003]
G00003:
  text: |-
    Some text
  supportedBy: [S00003, S00004]
#  horizontalIndex:
#    absolute: 3

S00003:
  text: |-
    Some text
  supportedBy: [Sn00002]
  inContextOf: [A00003, J00003, C00003]
  horizontalIndex:
    relative: 2
S00004:
  text: |-
    Some text
  supportedBy: [G00004]
  horizontalIndex:
    relative: 1
#  rankIncrement: 1

G00004:
  text: |-
    Some text
  supportedBy: [S00005]
  # undeveloped: true
S00005:
  text: |-
    Some text
  undeveloped: true
A00003:
  text: |-
    Some text
  horizontalIndex:
    relative: -1
#  rankIncrement: 5
#  horizontalIndex:
#    absolute: 1
J00003:
  text: |-
    Some text
  horizontalIndex:
    relative: -1
#  rankIncrement: 5
C00003:
  text: |-
    Some text
  horizontalIndex:
    relative: -1
Sn00002:
  text: |-
    Some text
  rankIncrement: 2
#  horizontalIndex:
#      relative: -1

Desktop (please complete the following information):

Fix

To fix this, I just had to swap the horizontal index of S00003 and S00004 and it worked fine

S00003:
  text: |
    Some text
  supportedBy: [Sn00002]
  inContextOf: [A00003, J00003, C00003]
  horizontalIndex:
      relative: 1

S00004:
  text: |
    Some text
  supportedBy: [G00004]
  horizontalIndex:
    relative: 2

Additional context

By the way, I could not use the keyword "uses", for some reason it tells me that the YAML is incorrect even though any verifier tells me it is valid. You'll notice I have commented out uses and manually provide all files to gsn2x.

Thanks!

jonasthewolf commented 2 months ago

@ecleipteon thank you very much for your kind and elaborate feedback.

I would consider this a bug, since there should be no crash, but rather an error message.

Unfortunately, I don't have access to my computer over the weekend.

I will work on this as soon as possible.

jonasthewolf commented 2 months ago

Ok @ecleipteon, I had a chance to have a look at your files. The problem is the "complete view". If you don't need that for the moment, you could temporarily use the -F option to disable it. I will let you know once I found a fix for the problem.

jonasthewolf commented 2 months ago

@ecleipteon good news, I think I just fixed the problem. I try to release a bug fix version tonight.

With respect to the "uses: does not work" problem. I cannot reproduce that. I uncommented your "uses:" statement, and it worked immediately after adapting the file name to the name I gave it for regression testing.

Your example misses an "s" by the way. This should however not lead to an unparsable YAML, but rather to an error message that the file is not found. Could you please double check that?

jonasthewolf commented 2 months ago

I just release v3.2.1 with a fix. Please open a new issue if the "uses:" problem persists.

ecleipteon commented 2 months ago

Thanks for the prompt fix! :-)

No problem, I will open another issue if I keep having troubles with using uses. It might be the s missing or perhaps some space/tab issue in my YAML that has disappeared following the anonymisation and the copy-pasting.

Thanks again!