{"action":"opened","issue":{"url":"https://api.github.com/repos/getpelican/pelican/issues/1963","repository_url":"https://api.github.com/repos/getpelican/pelican","labels_url":"https://api.github.com/repos/getpelican/pelican/issues/1963/labels{/name}","comments_url":"https://api.github.com/repos/getpelican/pelican/issues/1963/comments","events_url":"https://api.github.com/repos/getpelican/pelican/issues/1963/events","html_url":"https://github.com/getpelican/pelican/issues/1963","id":157335416,"number":1963,"title":"save_as and URL can't be arrays, but it's badly reported","user":{"login":"JulienPalard","id":239510,"avatar_url":"https://avatars.githubusercontent.com/u/239510?v=3","gravatar_id":"","url":"https://api.github.com/users/JulienPalard","html_url":"https://github.com/JulienPalard","followers_url":"https://api.github.com/users/JulienPalard/followers","following_url":"https://api.github.com/users/JulienPalard/following{/other_user}","gists_url":"https://api.github.com/users/JulienPalard/gists{/gist_id}","starred_url":"https://api.github.com/users/JulienPalard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JulienPalard/subscriptions","organizations_url":"https://api.github.com/users/JulienPalard/orgs","repos_url":"https://api.github.com/users/JulienPalard/repos","events_url":"https://api.github.com/users/JulienPalard/events{/privacy}","received_events_url":"https://api.github.com/users/JulienPalard/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-05-28T11:58:19Z","updated_at":"2016-05-28T11:58:19Z","closed_at":null,"body":"I had a problem with a file containing two \"save_as\" due to a bad `sed` (my fault):\r\n\r\n    $ grep -c ^save_as: content/the_problem.md \r\n    2\r\n\r\nThe problem is an exception raised from the `os.path.join` called in [writers.py's write_file](https://github.com/getpelican/pelican/blob/master/pelican/writers.py#L157)\r\n\r\nBut I don't think catching the exception anywhere can be the right way to do, I'd rather prefer detecting the error upfront, like in the reader, but it look like a checker is already implemented, in `contents.py`, named `check_properties` and it seems the ideal place to drop something like:\r\n\r\n    def check_properties(self):\r\n        \"\"\"Test mandatory properties are set.\"\"\"\r\n        string_like_only_properties = {'save_as', 'url'}\r\n        for prop in string_like_only_properties:\r\n            if hasattr(self, 'save_as') and isinstance(self.save_as, list):\r\n                raise ValueError(\"property save_as should not be a list in {}\"\r\n                                 \" (probably declared twice).\".format(self))\r\n        for prop in self.mandatory_properties:\r\n            if not hasattr(self, prop):\r\n                raise NameError(prop)\r\n\r\nGiving:\r\n>CRITICAL: ValueError: property save_as should not be a list in /home/mdk/pelican_test/content/the_problem.md (probably declared twice).\r\n\r\nInstead of:\r\n>CRITICAL: TypeError: join() argument must be str or bytes, not 'list'\r\n\r\nBut, before writing a PR, I'd like to know if there's other properties that have restrictions, I think of date being a parsable date, what else ? Why not checking if some properties are not empty ? Valid paths maybe ? I noted that starting a URL override with a `/` generate a link in the form `http://0.0.0.0/`, don't know if it's a real bug (I'm new to pelican) but if so, we can check it here too."}}
{"actor":{"display_login":"JulienPalard"}}