OpenSlides / openslides-autoupdate-service

Autoupdate service for OpenSlides 4+
MIT License
2 stars 21 forks source link

What is the `poll/0/id` and `poll/0/content_object_id`? #323

Closed GabrielInTheWorld closed 3 years ago

GabrielInTheWorld commented 3 years ago

As a "normal" user (no OML, group "staff" in meeting/1), I sent this request:

[
  {
    "collection":"meeting",
    "ids":[
      1
    ],
    "fields":{
      "name":null,
      "description":null,
      "location":null,
      "conference_show":null,
      "conference_auto_connect":null,
      "conference_los_restriction":null,
      "conference_stream_url":null,
      "conference_open_microphone":null,
      "conference_open_video":null,
      "conference_auto_connect_next_speakers":null,
      "conference_stream_poster_url":null,
      "conference_enable_helpdesk":null,
      "applause_enable":null,
      "applause_type":null,
      "applause_show_level":null,
      "applause_min_amount":null,
      "applause_max_amount":null,
      "applause_timeout":null,
      "applause_particle_image_url":null,
      "projector_countdown_warning_time":null,
      "projector_countdown_default_time":null,
      "enable_anonymous":null,
      "export_csv_separator":null,
      "export_csv_encoding":null,
      "export_pdf_pagenumber_alignment":null,
      "export_pdf_fontsize":null,
      "export_pdf_pagesize":null,
      "agenda_enable_numbering":null,
      "agenda_number_prefix":null,
      "agenda_numeral_system":null,
      "agenda_item_creation":null,
      "agenda_new_items_default_visibility":null,
      "agenda_show_internal_items_on_projector":null,
      "agenda_show_subtitles":null,
      "list_of_speakers_amount_last_on_projector":null,
      "list_of_speakers_amount_next_on_projector":null,
      "list_of_speakers_couple_countdown":null,
      "list_of_speakers_enable_point_of_order_speakers":null,
      "list_of_speakers_speaker_note_for_everyone":null,
      "list_of_speakers_show_amount_of_speakers_on_slide":null,
      "list_of_speakers_present_users_only":null,
      "list_of_speakers_show_first_contribution":null,
      "list_of_speakers_initially_closed":null,
      "list_of_speakers_enable_pro_contra_speech":null,
      "list_of_speakers_can_set_contribution_self":null,
      "motions_default_workflow_id":null,
      "motions_default_amendment_workflow_id":null,
      "motions_default_statute_amendment_workflow_id":null,
      "motions_preamble":null,
      "motions_default_line_numbering":null,
      "motions_line_length":null,
      "motions_reason_required":null,
      "motions_enable_text_on_projector":null,
      "motions_enable_reason_on_projector":null,
      "motions_enable_recommendation_on_projector":null,
      "motions_show_referring_motions":null,
      "motions_enable_sidebox_on_projector":null,
      "motions_show_sequential_number":null,
      "motions_recommendations_by":null,
      "motions_statute_recommendations_by":null,
      "motions_recommendation_text_mode":null,
      "motions_default_sorting":null,
      "motions_number_type":null,
      "motions_number_min_digits":null,
      "motions_number_with_blank":null,
      "motions_amendments_enabled":null,
      "motions_statutes_enabled":null,
      "motions_amendments_in_main_list":null,
      "motions_amendments_prefix":null,
      "motions_amendments_text_mode":null,
      "motions_amendments_multiple_paragraphs":null,
      "motions_amendments_of_amendments":null,
      "motions_supporters_min_amount":null,
      "motion_poll_default_type":null,
      "motion_poll_default_100_percent_base":null,
      "motion_poll_default_group_ids":null,
      "motion_poll_ballot_paper_selection":null,
      "motion_poll_ballot_paper_number":null,
      "motions_export_title":null,
      "motions_export_preamble":null,
      "motions_export_submitter_recommendation":null,
      "motions_export_follow_recommendation":null,
      "assignment_poll_default_method":null,
      "assignment_poll_default_type":null,
      "assignment_poll_default_100_percent_base":null,
      "assignment_poll_default_group_ids":null,
      "assignment_poll_add_candidates_to_list_of_speakers":null,
      "assignment_poll_sort_poll_result_by_votes":null,
      "assignment_poll_ballot_paper_selection":null,
      "assignment_poll_ballot_paper_number":null,
      "assignments_export_title":null,
      "assignments_export_preamble":null,
      "users_sort_by":null,
      "users_enable_presence_view":null,
      "users_allow_self_set_present":null,
      "users_enable_vote_weight":null,
      "users_pdf_welcometitle":null,
      "users_pdf_welcometext":null,
      "users_pdf_url":null,
      "users_pdf_wlan_ssid":null,
      "users_pdf_wlan_password":null,
      "users_pdf_wlan_encryption":null,
      "users_email_sender":null,
      "users_email_replyto":null,
      "users_email_subject":null,
      "users_email_body":null,
      "custom_translations":null,
      "jitsi_domain":null,
      "jitsi_room_name":null,
      "jitsi_room_password":null,
      "id":null,
      "logo_$_id":{
        "type":"template"
      },
      "font_$_id":{
        "type":"template"
      },
      "reference_projector_id":null,
      "default_group_id":{
        "type":"relation",
        "collection":"group",
        "fields":{
          "name":null,
          "permissions":null,
          "admin_group_for_meeting_id":null,
          "default_group_for_meeting_id":null,
          "id":null
        }
      },
      "admin_group_id":{
        "type":"relation",
        "collection":"group",
        "fields":{
          "name":null,
          "permissions":null,
          "admin_group_for_meeting_id":null,
          "default_group_for_meeting_id":null,
          "id":null
        }
      },
      "projector_ids":{
        "type":"relation-list",
        "collection":"projector",
        "fields":{
          "name":null,
          "scale":null,
          "scroll":null,
          "width":null,
          "aspect_ratio_numerator":null,
          "aspect_ratio_denominator":null,
          "color":null,
          "background_color":null,
          "header_background_color":null,
          "header_font_color":null,
          "header_h1_color":null,
          "chyron_background_color":null,
          "chyron_font_color":null,
          "show_header_footer":null,
          "show_title":null,
          "show_logo":null,
          "show_clock":null,
          "used_as_reference_projector_meeting_id":null,
          "id":null,
          "current_projection_ids":{
            "type":"relation-list",
            "collection":"projection",
            "fields":{
              "stable":null,
              "type":null,
              "options":null,
              "weight":null,
              "id":null,
              "content_object_id":{
                "type":"generic-relation",
                "fields":{
                  "title":null,
                  "number":null,
                  "created":null,
                  "sequential_number":null,
                  "text":null,
                  "reason":null,
                  "recommendation_id":null,
                  "tag_ids":null,
                  "personal_note_ids":null,
                  "block_id":null,
                  "category_id":null,
                  "lead_motion_id":null,
                  "comment_ids":null,
                  "modified_final_version":null,
                  "state_extension":null,
                  "recommendation_extension":null,
                  "agenda_item_id":null,
                  "amendment_paragraph_$":{
                    "type":"template"
                  },
                  "poll_ids":null,
                  "origin_id":null,
                  "id":null,
                  "is_directory":null,
                  "parent_id":null,
                  "child_ids":null,
                  "mimetype":null,
                  "filesize":null,
                  "create_timestamp":null,
                  "has_inherited_access_groups":null,
                  "pdf_information":null,
                  "closed":null,
                  "content_object_id":null,
                  "speaker_ids":null,
                  "internal":null,
                  "open_posts":null,
                  "phase":null,
                  "candidate_ids":null,
                  "description":null,
                  "default_poll_description":null,
                  "number_poll_candidates":null,
                  "item_number":null,
                  "comment":null,
                  "type":null,
                  "is_hidden":null,
                  "is_internal":null,
                  "duration":null,
                  "weight":null,
                  "level":null,
                  "meeting_id":null,
                  "first_name":null,
                  "last_name":null,
                  "username":null,
                  "vote_weight_$":{
                    "type":"template"
                  },
                  "structure_level_$":{
                    "type":"template"
                  },
                  "number_$":{
                    "type":"template"
                  },
                  "email":null,
                  "gender":null,
                  "is_active":null,
                  "is_physical_person":null,
                  "is_present_in_meeting_ids":null,
                  "last_email_send":null,
                  "default_number":null,
                  "default_structure_level":null,
                  "default_vote_weight":null,
                  "comment_$":{
                    "type":"template"
                  },
                  "about_me_$":{
                    "type":"template"
                  },
                  "default_password":null,
                  "entitled_group_ids":null,
                  "state":null,
                  "pollmethod":null,
                  "voted_ids":null,
                  "votescast":null,
                  "votesinvalid":null,
                  "votesvalid":null,
                  "option_ids":null,
                  "onehundred_percent_base":null,
                  "global_option_id":null,
                  "global_yes":null,
                  "global_no":null,
                  "global_abstain":null,
                  "min_votes_amount":null,
                  "max_votes_amount":null,
                  "entitled_users_at_stop":null,
                  "message":null,
                  "default_time":null,
                  "countdown_time":null,
                  "running":null
                }
              }
            }
          },
          "preview_projection_ids":{
            "type":"relation-list",
            "collection":"projection",
            "fields":{
              "stable":null,
              "type":null,
              "options":null,
              "weight":null,
              "id":null,
              "content_object_id":{
                "type":"generic-relation",
                "fields":{
                  "title":null,
                  "number":null,
                  "created":null,
                  "sequential_number":null,
                  "text":null,
                  "reason":null,
                  "recommendation_id":null,
                  "tag_ids":null,
                  "personal_note_ids":null,
                  "block_id":null,
                  "category_id":null,
                  "lead_motion_id":null,
                  "comment_ids":null,
                  "modified_final_version":null,
                  "state_extension":null,
                  "recommendation_extension":null,
                  "agenda_item_id":null,
                  "amendment_paragraph_$":{
                    "type":"template"
                  },
                  "poll_ids":null,
                  "origin_id":null,
                  "id":null,
                  "is_directory":null,
                  "parent_id":null,
                  "child_ids":null,
                  "mimetype":null,
                  "filesize":null,
                  "create_timestamp":null,
                  "has_inherited_access_groups":null,
                  "pdf_information":null,
                  "closed":null,
                  "content_object_id":null,
                  "speaker_ids":null,
                  "internal":null,
                  "open_posts":null,
                  "phase":null,
                  "candidate_ids":null,
                  "description":null,
                  "default_poll_description":null,
                  "number_poll_candidates":null,
                  "item_number":null,
                  "comment":null,
                  "type":null,
                  "is_hidden":null,
                  "is_internal":null,
                  "duration":null,
                  "weight":null,
                  "level":null,
                  "meeting_id":null,
                  "first_name":null,
                  "last_name":null,
                  "username":null,
                  "vote_weight_$":{
                    "type":"template"
                  },
                  "structure_level_$":{
                    "type":"template"
                  },
                  "number_$":{
                    "type":"template"
                  },
                  "email":null,
                  "gender":null,
                  "is_active":null,
                  "is_physical_person":null,
                  "is_present_in_meeting_ids":null,
                  "last_email_send":null,
                  "default_number":null,
                  "default_structure_level":null,
                  "default_vote_weight":null,
                  "comment_$":{
                    "type":"template"
                  },
                  "about_me_$":{
                    "type":"template"
                  },
                  "default_password":null,
                  "entitled_group_ids":null,
                  "state":null,
                  "pollmethod":null,
                  "voted_ids":null,
                  "votescast":null,
                  "votesinvalid":null,
                  "votesvalid":null,
                  "option_ids":null,
                  "onehundred_percent_base":null,
                  "global_option_id":null,
                  "global_yes":null,
                  "global_no":null,
                  "global_abstain":null,
                  "min_votes_amount":null,
                  "max_votes_amount":null,
                  "entitled_users_at_stop":null,
                  "message":null,
                  "default_time":null,
                  "countdown_time":null,
                  "running":null
                }
              }
            }
          }
        }
      },
      "poll_ids":{
        "type":"relation-list",
        "collection":"poll",
        "fields":{
          "entitled_group_ids":null,
          "state":null,
          "title":null,
          "type":null,
          "pollmethod":null,
          "content_object_id":{
            "type":"generic-relation",
            "fields":{
              "title":null,
              "number":null,
              "created":null,
              "sequential_number":null,
              "text":null,
              "reason":null,
              "recommendation_id":null,
              "tag_ids":null,
              "personal_note_ids":null,
              "block_id":null,
              "category_id":null,
              "lead_motion_id":null,
              "comment_ids":null,
              "modified_final_version":null,
              "state_extension":null,
              "recommendation_extension":null,
              "agenda_item_id":null,
              "amendment_paragraph_$":{
                "type":"template"
              },
              "poll_ids":null,
              "origin_id":null,
              "id":null,
              "open_posts":null,
              "phase":null,
              "candidate_ids":null,
              "description":null,
              "default_poll_description":null,
              "number_poll_candidates":null
            }
          },
          "id":null,
          "voted_ids":null
        }
      },
      "default_projector_$_id":{
        "type":"template",
        "values":{
          "type":"relation",
          "collection":"projector",
          "fields":{
            "name":null,
            "scale":null,
            "scroll":null,
            "width":null,
            "aspect_ratio_numerator":null,
            "aspect_ratio_denominator":null,
            "color":null,
            "background_color":null,
            "header_background_color":null,
            "header_font_color":null,
            "header_h1_color":null,
            "chyron_background_color":null,
            "chyron_font_color":null,
            "show_header_footer":null,
            "show_title":null,
            "show_logo":null,
            "show_clock":null,
            "used_as_reference_projector_meeting_id":null,
            "id":null
          }
        }
      }
    }
  }
]

The AU-service responds me with this error:

"the given keys/fqfields are invalid: [poll/0/id poll/0/content_object_id]"

The meeting/1 is the "default" meeting inserted by the initial-data.json.

Can you explain me, why this error happens?

ostcar commented 3 years ago

I found the bug. But I don't know how to solve this. @tsiegleauq I think, I need your help

Here is a simpler request that produces the same error:

curl -N localhost:9012/system/autoupdate -d '[
  {
    "collection":"projection",
    "ids":[
      3
    ],
    "fields":{
        "content_object_id":{
            "type":"generic-relation",
            "fields":{
                "option_ids":null
            }
        }
    }
  }
]'

It requests projection/3/content_object_id. The value is meeting/1

Then, it requests the field option_ids. So it requests meeting/1/option_ids. The value is a list of all known options

Then, this list is given to the restricter, that removes all ids from options, that the user is not allowed to see. Therefore it goes throw the rules of option-see-property

The rule is, that someone can see the option, if the user can see the linked poll.

But the linked poll for option/2 is null

The restricter translates the value null to 0 and therefore checks if the user can see poll/0/id. This returns in the given error.

So the question is: Do all option have a linked poll? If yes, then the example data are invalid. If not, the see-property of option has to be changed to handle options without a poll.

GabrielInTheWorld commented 3 years ago

@ostcar since the client cannot create any options, options will be always created when a poll is created, there will never be an option without a linked poll.

GabrielInTheWorld commented 3 years ago

So the question is: Do all option have a linked poll? If yes, then the example data are invalid. If not, the see-property of option has to be changed to handle options without a poll.

The example data might be invalid.