Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Format stacktrace to fit edge_list body #2187

Closed
Tracked by #2168
kevkevinpal opened this issue Dec 13, 2024 · 2 comments · Fixed by #2215
Closed
Tracked by #2168

Format stacktrace to fit edge_list body #2187

kevkevinpal opened this issue Dec 13, 2024 · 2 comments · Fixed by #2215
Assignees

Comments

@kevkevinpal
Copy link
Contributor

kevkevinpal commented Dec 13, 2024

First #2186 needs to be finished

Goal

We want to format the stacktrace to an object named edge list

We would want to create this as a util and write some tests on this util to insure that it works properly

here is an example object which we need to format it to

{
    "edge_list": [
        {
            "edge": {
                "edge_type": "GENERATED_BY",
                "weight": 1
            },
            "source": {
                "node_type": "Report",
                "node_data": {
                    "app_type": null,
                    "errors": "undefined method `map' for nil:NilClass",
                    "release_stage": "development",
                    "report_id": "1806752cedca30ea21e35e8e38b8e257bb8b35b9_app/services/pricing_policy_import_service.rb_9",
                    "severity_reason": "unhandledException",
                    "severity": "error",
                    "time_generated": 1729596500
                }
            },
            "targets": [
                {
                    "node_type": "Application",
                    "node_data": {
                        "app_type": null,
                        "application_id": "stakwork",
                        "environment": "development",
                        "framework": "rails",
                        "language": "ruby",
                        "release_stage": "development",
                        "repository": null
                    }
                }
            ]
        },
        {
            "edge": {
                "edge_type": "HAS",
                "weight": 1
            },
            "source": {
                "node_type": "Report",
                "node_data": {
                    "report_id": "1806752cedca30ea21e35e8e38b8e257bb8b35b9_app/services/pricing_policy_import_service.rb_9",
                    "time_generated": 1729596500,
                    "errors": "undefined method `map' for nil:NilClass"
                }
            },
            "targets": [
                {
                    "node_type": "User",
                    "node_data": {
                        "user_id": "development"
                    }
                }
            ]
        },
        {
            "edge": {
                "edge_type": "HAS",
                "weight": 1
            },
            "source": {
                "node_type": "Report",
                "node_data": {
                    "report_id": "1806752cedca30ea21e35e8e38b8e257bb8b35b9_app/services/pricing_policy_import_service.rb_9",
                    "time_generated": 1729596500,
                    "errors": "undefined method `map' for nil:NilClass"
                }
            },
            "targets": [
                {
                    "node_type": "BugEvent",
                    "node_data": {
                        "metadata": "{\"authenticity_token\":\"D0FSRNR0wJY0hkPlpxulgTO0hML4golvb4j+ZSDdA8+eDh6WUJRcRbCV32fl2/gtenki6Hte+35+7TwFiSBXVw==\",\"workflow\":{\"name\":\"test\"},\"spec\":\"{\\\"asdsaddas\\\": \\\"\\\"}\",\"commit\":\"Import\",\"controller\":\"admin/workflows\",\"action\":\"import_workflow\"}",
                        "commit_id": null,
                        "bug_event_uuid": "1806752cedca30ea21e35e8e38b8e257bb8b35b9_app/services/pricing_policy_import_service.rb_9_1729596500"
                    }
                }
            ]
        },
        {
            "edge": {
                "edge_type": "HAS",
                "weight": 1
            },
            "source": {
                "node_type": "BugEvent",
                "node_data": {
                    "bug_event_uuid": "1806752cedca30ea21e35e8e38b8e257bb8b35b9_app/services/pricing_policy_import_service.rb_9_1729596500"
                }
            },
            "targets": [
                {
                    "node_type": "Stacktrace",
                    "node_data": {
                        "frames": "app/services/pricing_policy_import_service.rb:9\\napp/services/workflow_import_service.rb:12\\napp/services/workflow_import_service.rb:12\\napp/models/concerns/workflow_transfer_concern.rb:19\\ngems/activerecord-6.1.7.6/lib/active_record/connection_adapters/abstract/database_statements.rb:320\\ngems/activerecord-6.1.7.6/lib/active_record/connection_adapters/abstract/transaction.rb:319\\ngems/activesupport-6.1.7.6/lib/active_support/concurrency/load_interlock_aware_monitor.rb:26\\ngems/activesupport-6.1.7.6/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25\\ngems/activesupport-6.1.7.6/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25\\ngems/activesupport-6.1.7.6/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21\\ngems/activesupport-6.1.7.6/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21\\ngems/activerecord-6.1.7.6/lib/active_record/connection_adapters/abstract/transaction.rb:317\\ngems/activerecord-6.1.7.6/lib/active_record/connection_adapters/abstract/database_statements.rb:320\\ngems/activerecord-6.1.7.6/lib/active_record/transactions.rb:209\\napp/models/concerns/workflow_transfer_concern.rb:17\\ngems/actionpack-6.1.7.6/lib/action_controller/metal/basic_implicit_render.rb:6\\ngems/actionpack-6.1.7.6/lib/abstract_controller/base.rb:228\\ngems/actionpack-6.1.7.6/lib/action_controller/metal/rendering.rb:30\\ngems/actionpack-6.1.7.6/lib/abstract_controller/callbacks.rb:42\\ngems/activesupport-6.1.7.6/lib/active_support/callbacks.rb:117\\ngems/activesupport-6.1.7.6/lib/active_support/core_ext/time/zones.rb:66\\napp/controllers/admin2_controller.rb:88\\ngems/activesupport-6.1.7.6/lib/active_support/callbacks.rb:126\\napp/controllers/admin2_controller.rb:94\\ngems/dry-effects-0.1.5/lib/dry/effects/frame.rb:39",
                        "stack_trace_id": "9a6a9a3f-7609-4870-b287-4e95f2c29c80"
                    }
                }
            ]
        },
        {
            "edge": {
                "edge_type": "CONTAINS",
                "weight": 1
            },
            "source": {
                "node_type": "Stacktrace",
                "node_data": {
                    "stack_trace_id": "9a6a9a3f-7609-4870-b287-4e95f2c29c80"
                }
            },
            "targets": [
                {
                    "node_type": "Trace",
                    "node_data": {
                        "line_number": 9,
                        "file": "app/services/pricing_policy_import_service.rb",
                        "method": "initialize",
                        "code": "  def initialize(spec, current_user)\\n    @spec = spec\\n    @current_user = current_user\\n    @policy_id_mappings = spec.map { |policy| import_pricing_policy(policy) }\\n  end\\n\\n  private",
                        "trace_uuid": "c0e1233e-b117-4ded-a364-e15b2d1ff564"
                    }
                }
            ]
        },
        {
            "edge": {
                "edge_type": "CONTAINS",
                "weight": 1
            },
            "source": {
                "node_type": "Stacktrace",
                "node_data": {
                    "stack_trace_id": "9a6a9a3f-7609-4870-b287-4e95f2c29c80"
                }
            },
            "targets": [
                {
                    "node_type": "Trace",
                    "node_data": {
                        "line_number": 12,
                        "file": "app/services/workflow_import_service.rb",
                        "method": "new",
                        "code": "  end\\n\\n  def import_related_items!\\n    policy_importer = PricingPolicyImportService.new(workflow_spec['pricing_policies'], current_user)\\n    skill_importer = SkillImportService.new(workflow_spec['subskills'], current_user)\\n\\n    update_workflow_params(workflow_spec, policy_importer.policy_id_mappings, skill_importer.skill_id_mappings)",
                        "trace_uuid": "f2d1ba91-bf3f-4fd8-81c9-5cefb3dc86de"
                    }
                }
            ]
        },
        {
            "edge": {
                "edge_type": "CONTAINS",
                "weight": 1
            },
            "source": {
                "node_type": "Stacktrace",
                "node_data": {
                    "stack_trace_id": "9a6a9a3f-7609-4870-b287-4e95f2c29c80"
                }
            },
            "targets": [
                {
                    "node_type": "Trace",
                    "node_data": {
                        "line_number": 12,
                        "file": "app/services/workflow_import_service.rb",
                        "method": "import_related_items!",
                        "code": "  end\\n\\n  def import_related_items!\\n    policy_importer = PricingPolicyImportService.new(workflow_spec['pricing_policies'], current_user)\\n    skill_importer = SkillImportService.new(workflow_spec['subskills'], current_user)\\n\\n    update_workflow_params(workflow_spec, policy_importer.policy_id_mappings, skill_importer.skill_id_mappings)",
                        "trace_uuid": "7c1c73ed-406a-434a-9d68-b3b7f5e2f4be"
                    }
                }
            ]
        },
        {
            "edge": {
                "edge_type": "CONTAINS",
                "weight": 1
            },
            "source": {
                "node_type": "Stacktrace",
                "node_data": {
                    "stack_trace_id": "9a6a9a3f-7609-4870-b287-4e95f2c29c80"
                }
            },
            "targets": [
                {
                    "node_type": "Trace",
                    "node_data": {
                        "line_number": 19,
                        "file": "app/models/concerns/workflow_transfer_concern.rb",
                        "method": "block in import_workflow",
                        "code": "\\n    Workflow.transaction do\\n      import_workflow_service = WorkflowImportService.new(spec, current_user)\\n      import_workflow_service.import_related_items!\\n\\n      workflow_attributes = {}\\n      workflow_attributes['name'] = params['workflow']['name']",
                        "trace_uuid": "394579d3-93e4-4ef1-bd54-c3a634600032"
                    }
                }
            ]
        },
        {
            "edge": {
                "edge_type": "CONTAINS",
                "weight": 1
            },
            "source": {
                "node_type": "Stacktrace",
                "node_data": {
                    "stack_trace_id": "9a6a9a3f-7609-4870-b287-4e95f2c29c80"
                }
            },
            "targets": [
                {
                    "node_type": "Trace",
                    "node_data": {
                        "line_number": 17,
                        "file": "app/models/concerns/workflow_transfer_concern.rb",
                        "method": "import_workflow",
                        "code": "  def import_workflow\\n    spec = JSON.parse(params[:spec])\\n\\n    Workflow.transaction do\\n      import_workflow_service = WorkflowImportService.new(spec, current_user)\\n      import_workflow_service.import_related_items!\\n",
                        "trace_uuid": "c32bd77d-f8f8-47f9-a437-5a0dc4cc5513"
                    }
                }
            ]
        },
        {
            "edge": {
                "edge_type": "CONTAINS",
                "weight": 1
            },
            "source": {
                "node_type": "Stacktrace",
                "node_data": {
                    "stack_trace_id": "9a6a9a3f-7609-4870-b287-4e95f2c29c80"
                }
            },
            "targets": [
                {
                    "node_type": "Trace",
                    "node_data": {
                        "line_number": 88,
                        "file": "app/controllers/admin2_controller.rb",
                        "method": "user_time_zone",
                        "code": "  end\\n\\n  def user_time_zone(\u0026block)\\n    Time.use_zone(current_user.timezone, \u0026block)\\n  end\\n\\n  private",
                        "trace_uuid": "828bc3d0-2068-4a74-b4e4-7392a11fd3f0"
                    }
                }
            ]
        },
        {
            "edge": {
                "edge_type": "CONTAINS",
                "weight": 1
            },
            "source": {
                "node_type": "Stacktrace",
                "node_data": {
                    "stack_trace_id": "9a6a9a3f-7609-4870-b287-4e95f2c29c80"
                }
            },
            "targets": [
                {
                    "node_type": "Trace",
                    "node_data": {
                        "line_number": 94,
                        "file": "app/controllers/admin2_controller.rb",
                        "method": "block in set_current_user",
                        "code": "\\n  private\\n\\n  def set_current_user\\n    with_current_user(current_user) { yield }\\n  end\\nend",
                        "trace_uuid": "f23b3034-c585-406f-948e-ab0d50fb5ae8"
                    }
                }
            ]
        },
        {
            "edge": {
                "edge_type": "NEXT",
                "weight": 1
            },
            "source": {
                "node_type": "Trace",
                "node_data": {
                    "trace_uuid": "f2d1ba91-bf3f-4fd8-81c9-5cefb3dc86de"
                }
            },
            "targets": [
                {
                    "node_type": "Trace",
                    "node_data": {
                        "trace_uuid": "c0e1233e-b117-4ded-a364-e15b2d1ff564"
                    }
                }
            ]
        },
        {
            "edge": {
                "edge_type": "NEXT",
                "weight": 1
            },
            "source": {
                "node_type": "Trace",
                "node_data": {
                    "trace_uuid": "7c1c73ed-406a-434a-9d68-b3b7f5e2f4be"
                }
            },
            "targets": [
                {
                    "node_type": "Trace",
                    "node_data": {
                        "trace_uuid": "f2d1ba91-bf3f-4fd8-81c9-5cefb3dc86de"
                    }
                }
            ]
        },
        {
            "edge": {
                "edge_type": "NEXT",
                "weight": 1
            },
            "source": {
                "node_type": "Trace",
                "node_data": {
                    "trace_uuid": "394579d3-93e4-4ef1-bd54-c3a634600032"
                }
            },
            "targets": [
                {
                    "node_type": "Trace",
                    "node_data": {
                        "trace_uuid": "7c1c73ed-406a-434a-9d68-b3b7f5e2f4be"
                    }
                }
            ]
        },
        {
            "edge": {
                "edge_type": "NEXT",
                "weight": 1
            },
            "source": {
                "node_type": "Trace",
                "node_data": {
                    "trace_uuid": "c32bd77d-f8f8-47f9-a437-5a0dc4cc5513"
                }
            },
            "targets": [
                {
                    "node_type": "Trace",
                    "node_data": {
                        "trace_uuid": "394579d3-93e4-4ef1-bd54-c3a634600032"
                    }
                }
            ]
        },
        {
            "edge": {
                "edge_type": "NEXT",
                "weight": 1
            },
            "source": {
                "node_type": "Trace",
                "node_data": {
                    "trace_uuid": "828bc3d0-2068-4a74-b4e4-7392a11fd3f0"
                }
            },
            "targets": [
                {
                    "node_type": "Trace",
                    "node_data": {
                        "trace_uuid": "c32bd77d-f8f8-47f9-a437-5a0dc4cc5513"
                    }
                }
            ]
        },
        {
            "edge": {
                "edge_type": "NEXT",
                "weight": 1
            },
            "source": {
                "node_type": "Trace",
                "node_data": {
                    "trace_uuid": "f23b3034-c585-406f-948e-ab0d50fb5ae8"
                }
            },
            "targets": [
                {
                    "node_type": "Trace",
                    "node_data": {
                        "trace_uuid": "828bc3d0-2068-4a74-b4e4-7392a11fd3f0"
                    }
                }
            ]
        }
    ]
}
@MahtabBukhari
Copy link
Contributor

@kevkevinpal please assign

@aliraza556
Copy link
Contributor

@kevkevinpal Please assign me to this issue. It has been completed: #2186.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants